-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathfinalizeDependencies.test.ts
97 lines (88 loc) · 3.55 KB
/
finalizeDependencies.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { describe, expect, it, vi } from "vitest";
import { Options } from "../shared/types.js";
import { finalizeDependencies } from "./finalizeDependencies.js";
const mockExecaCommand = vi.fn();
vi.mock("execa", () => ({
get execaCommand() {
return mockExecaCommand;
},
}));
vi.mock("../shared/packages.js", () => ({
readPackageData: () => [],
removeDependencies: vi.fn(),
}));
const options = {
access: "public",
author: undefined,
base: "everything",
createRepository: undefined,
description: "Stub description.",
email: {
github: "[email protected]",
npm: "[email protected]",
},
excludeAllContributors: undefined,
excludeCompliance: undefined,
excludeLintJson: undefined,
excludeLintKnip: undefined,
excludeLintMd: undefined,
excludeLintPackageJson: undefined,
excludeLintPackages: undefined,
excludeLintPerfectionist: undefined,
excludeLintSpelling: undefined,
excludeLintYml: undefined,
excludeReleases: undefined,
excludeRenovate: undefined,
excludeTests: undefined,
funding: undefined,
logo: undefined,
mode: "create",
owner: "StubOwner",
repository: "stub-repository",
skipGitHubApi: false,
skipInstall: undefined,
skipRemoval: undefined,
skipRestore: undefined,
skipUninstall: undefined,
title: "Stub Title",
} satisfies Options;
describe("finalize", () => {
it("installs the full list of commands when no options are enabled", async () => {
await finalizeDependencies(options);
expect(mockExecaCommand.mock.calls).toMatchInlineSnapshot(`
[
[
"pnpm add @release-it/conventional-changelog@latest @types/eslint@latest @typescript-eslint/eslint-plugin@latest @typescript-eslint/parser@latest @vitest/coverage-v8@latest all-contributors-cli@latest console-fail-test@latest cspell@latest eslint@latest eslint-plugin-deprecation@latest eslint-plugin-eslint-comments@latest eslint-plugin-jsdoc@latest eslint-plugin-jsonc@latest eslint-plugin-markdown@latest eslint-plugin-n@latest eslint-plugin-no-only-tests@latest eslint-plugin-perfectionist@latest eslint-plugin-regexp@latest eslint-plugin-vitest@latest eslint-plugin-yml@latest husky@latest jsonc-eslint-parser@latest knip@latest lint-staged@latest markdownlint@latest markdownlint-cli@latest npm-package-json-lint@latest npm-package-json-lint-config-default@latest prettier@latest prettier-plugin-curly@latest prettier-plugin-packagejson@latest release-it@latest sentences-per-line@latest should-semantic-release@latest tsup@latest typescript@latest vitest@latest yaml-eslint-parser@latest -D",
],
[
"npx all-contributors-cli generate",
],
]
`);
});
it("installs the base list of commands when all options are enabled", async () => {
await finalizeDependencies({
...options,
excludeAllContributors: true,
excludeCompliance: true,
excludeLintJson: true,
excludeLintKnip: true,
excludeLintMd: true,
excludeLintPackageJson: true,
excludeLintPackages: true,
excludeLintPerfectionist: true,
excludeLintSpelling: true,
excludeLintYml: true,
excludeReleases: true,
excludeRenovate: undefined,
excludeTests: true,
});
expect(mockExecaCommand.mock.calls).toMatchInlineSnapshot(`
[
[
"pnpm add @types/eslint@latest @typescript-eslint/eslint-plugin@latest @typescript-eslint/parser@latest eslint@latest eslint-plugin-deprecation@latest eslint-plugin-eslint-comments@latest eslint-plugin-jsdoc@latest eslint-plugin-n@latest eslint-plugin-regexp@latest husky@latest lint-staged@latest prettier@latest prettier-plugin-curly@latest prettier-plugin-packagejson@latest tsup@latest typescript@latest -D",
],
]
`);
});
});