forked from JoshuaKGoldberg/create-typescript-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetBase.test.ts
57 lines (51 loc) · 1.22 KB
/
getBase.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
import { describe, expect, it, vi } from "vitest";
import { getBase } from "./getBase.js";
const mockReadPackageData = vi.fn();
vi.mock("../packages.js", () => ({
get readPackageData() {
return mockReadPackageData;
},
}));
describe("getBase", () => {
it("should return minimum with minimum scripts", async () => {
mockReadPackageData.mockImplementationOnce(() =>
Promise.resolve({
scripts: {
build: "build",
lint: "lint",
test: "test",
},
}),
);
expect(await getBase()).toBe("minimum");
});
it("should return common with common scripts", async () => {
mockReadPackageData.mockImplementationOnce(() =>
Promise.resolve({
scripts: {
build: "build",
lint: "lint",
"lint:knip": "knip",
test: "test",
},
}),
);
expect(await getBase()).toBe("common");
});
it("should return everything with everything scripts", async () => {
mockReadPackageData.mockImplementationOnce(() =>
Promise.resolve({
scripts: {
build: "build",
lint: "lint",
"lint:knip": "knip",
"lint:md": "md",
"lint:package-json": "package-json",
"lint:packages": "packages",
test: "test",
},
}),
);
expect(await getBase()).toBe("everything");
});
});