-
-
Notifications
You must be signed in to change notification settings - Fork 428
Expand file tree
/
Copy pathbasic.test.ts
More file actions
42 lines (35 loc) · 1.06 KB
/
basic.test.ts
File metadata and controls
42 lines (35 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import * as fs from "node:fs/promises";
import * as os from "node:os";
import * as path from "node:path";
import { afterAll, beforeAll, describe, expect, test } from "vitest";
import { generateApi } from "../../../src/index.js";
describe("basic", async () => {
let tmpdir = "";
beforeAll(async () => {
tmpdir = await fs.mkdtemp(path.join(os.tmpdir(), "swagger-typescript-api"));
});
afterAll(async () => {
await fs.rm(tmpdir, { recursive: true });
});
test("modular", async () => {
await generateApi({
fileName: "schema",
input: path.resolve(import.meta.dirname, "schema.json"),
output: tmpdir,
silent: true,
// @ts-expect-error: fixed in 13.2.8
modular: true,
});
const api = await fs.readFile(path.join(tmpdir, "Api.ts"), {
encoding: "utf8",
});
const dataContracts = await fs.readFile(
path.join(tmpdir, "data-contracts.ts"),
{
encoding: "utf8",
},
);
expect(api).toMatchSnapshot("api");
expect(dataContracts).toMatchSnapshot("dataContracts");
});
});