-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathgenerate.test.ts
66 lines (56 loc) · 1.71 KB
/
generate.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { existsSync, readFileSync } from "node:fs";
import { rm } from "node:fs/promises";
import path from "node:path";
import { afterAll, beforeAll, describe, expect, test } from "vitest";
import type { LimitedUserConfig } from "../src/cli.mts";
import { generate } from "../src/generate.mjs";
const readOutput = (fileName: string) => {
return readFileSync(
path.join(__dirname, "outputs", "queries", fileName),
"utf-8",
);
};
describe("generate", () => {
beforeAll(async () => {
const options: LimitedUserConfig = {
input: path.join(__dirname, "inputs", "petstore.yaml"),
output: path.join("tests", "outputs"),
client: "@hey-api/client-fetch",
lint: "biome",
format: "biome",
pageParam: "page",
nextPageParam: "meta.next",
initialPageParam: "initial",
operationId: true,
};
await generate(options, "1.0.0");
});
afterAll(async () => {
if (existsSync(path.join(__dirname, "outputs"))) {
await rm(path.join(__dirname, "outputs"), {
recursive: true,
});
}
});
test("common.ts", () => {
expect(readOutput("common.ts")).toMatchSnapshot();
});
test("queries.ts", () => {
expect(readOutput("queries.ts")).toMatchSnapshot();
});
test("infiniteQueries.ts", () => {
expect(readOutput("infiniteQueries.ts")).toMatchSnapshot();
});
test("index.ts", () => {
expect(readOutput("index.ts")).toMatchSnapshot();
});
test("suspense.ts", () => {
expect(readOutput("suspense.ts")).toMatchSnapshot();
});
test("prefetch.ts", () => {
expect(readOutput("prefetch.ts")).toMatchSnapshot();
});
test("ensureQueryData.ts", () => {
expect(readOutput("ensureQueryData.ts")).toMatchSnapshot();
});
});