-
-
Notifications
You must be signed in to change notification settings - Fork 386
/
Copy pathbasic.test.ts
37 lines (29 loc) · 936 Bytes
/
basic.test.ts
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
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("--axios --single-http-client", async () => {
await generateApi({
fileName: "schema",
input: path.resolve(import.meta.dirname, "schema.json"),
output: tmpdir,
silent: true,
generateClient: true,
httpClientType: "axios",
singleHttpClient: true,
});
const content = await fs.readFile(path.join(tmpdir, "schema.ts"), {
encoding: "utf8",
});
expect(content).toMatchSnapshot();
});
});