-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathcreateRerunSuggestion.test.ts
160 lines (138 loc) · 6.67 KB
/
createRerunSuggestion.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import { describe, expect, it } from "vitest";
import { getExclusions } from "../shared/options/exclusionKeys.js";
import { Options } from "../shared/types.js";
import { createRerunSuggestion } from "./createRerunSuggestion.js";
const options = {
access: "public",
author: "TestAuthor",
base: "everything",
description: "Test description.",
directory: ".",
email: {
github: "[email protected]",
npm: "[email protected]",
},
excludeAllContributors: true,
excludeCompliance: true,
excludeLintJSDoc: true,
excludeLintJson: true,
excludeLintKnip: true,
excludeLintMd: false,
excludeLintPackageJson: true,
excludeLintPackages: false,
excludeLintPerfectionist: true,
excludeLintSpelling: false,
excludeLintYml: false,
excludeReleases: false,
excludeRenovate: undefined,
excludeTests: undefined,
funding: undefined,
keywords: ["abc", "def ghi", "jkl mno pqr"],
mode: "create",
owner: "TestOwner",
repository: "test-repository",
skipGitHubApi: true,
skipInstall: true,
skipRemoval: true,
skipRestore: undefined,
skipUninstall: undefined,
title: "Test Title",
} satisfies Options;
describe("createRerunSuggestion", () => {
it("prints no options when no options are provided", () => {
const actual = createRerunSuggestion({});
expect(actual).toMatchInlineSnapshot(`"npx create-typescript-app"`);
});
it("prints only mode when no other options are provided", () => {
const actual = createRerunSuggestion({
mode: "create",
});
expect(actual).toMatchInlineSnapshot(
`"npx create-typescript-app --mode create"`,
);
});
it("includes key-value pairs with mixed truthy and falsy values", () => {
const actual = createRerunSuggestion(options);
expect(actual).toMatchInlineSnapshot(
`"npx create-typescript-app --base everything --author TestAuthor --description "Test description." --directory . --email-github [email protected] --email-npm [email protected] --exclude-all-contributors --exclude-compliance --exclude-lint-jsdoc --exclude-lint-json --exclude-lint-knip --exclude-lint-package-json --exclude-lint-perfectionist --keywords "abc def ghi jkl mno pqr" --mode create --owner TestOwner --repository test-repository --skip-github-api --skip-install --skip-removal --title "Test Title""`,
);
});
it("includes a non-default value when specified", () => {
const actual = createRerunSuggestion({
...options,
access: "restricted",
});
expect(actual).toMatchInlineSnapshot(
`"npx create-typescript-app --base everything --access restricted --author TestAuthor --description "Test description." --directory . --email-github [email protected] --email-npm [email protected] --exclude-all-contributors --exclude-compliance --exclude-lint-jsdoc --exclude-lint-json --exclude-lint-knip --exclude-lint-package-json --exclude-lint-perfectionist --keywords "abc def ghi jkl mno pqr" --mode create --owner TestOwner --repository test-repository --skip-github-api --skip-install --skip-removal --title "Test Title""`,
);
});
it("includes stringified guide when it exists", () => {
const actual = createRerunSuggestion({
...options,
guide: {
href: "https://example.com",
title: "Test Title",
},
mode: "initialize",
});
expect(actual).toMatchInlineSnapshot(
`"npx create-typescript-app --base everything --author TestAuthor --description "Test description." --directory . --email-github [email protected] --email-npm [email protected] --exclude-all-contributors --exclude-compliance --exclude-lint-jsdoc --exclude-lint-json --exclude-lint-knip --exclude-lint-package-json --exclude-lint-perfectionist --guide https://example.com --guide-title "Test Title" --keywords "abc def ghi jkl mno pqr" --mode initialize --owner TestOwner --repository test-repository --skip-github-api --skip-install --skip-removal --title "Test Title""`,
);
});
it("includes stringified logo when it exists", () => {
const actual = createRerunSuggestion({
...options,
logo: {
alt: "Test alt.",
src: "test/src.png",
},
mode: "initialize",
});
expect(actual).toMatchInlineSnapshot(
`"npx create-typescript-app --base everything --author TestAuthor --description "Test description." --directory . --email-github [email protected] --email-npm [email protected] --exclude-all-contributors --exclude-compliance --exclude-lint-jsdoc --exclude-lint-json --exclude-lint-knip --exclude-lint-package-json --exclude-lint-perfectionist --keywords "abc def ghi jkl mno pqr" --logo test/src.png --logo-alt "Test alt." --mode initialize --owner TestOwner --repository test-repository --skip-github-api --skip-install --skip-removal --title "Test Title""`,
);
});
it("includes exclusions when they exist", () => {
const actual = createRerunSuggestion({
...options,
excludeCompliance: true,
excludeLintMd: true,
excludeLintSpelling: true,
mode: "initialize",
});
expect(actual).toMatchInlineSnapshot(
`"npx create-typescript-app --base everything --author TestAuthor --description "Test description." --directory . --email-github [email protected] --email-npm [email protected] --exclude-all-contributors --exclude-compliance --exclude-lint-jsdoc --exclude-lint-json --exclude-lint-knip --exclude-lint-md --exclude-lint-package-json --exclude-lint-perfectionist --exclude-lint-spelling --keywords "abc def ghi jkl mno pqr" --mode initialize --owner TestOwner --repository test-repository --skip-github-api --skip-install --skip-removal --title "Test Title""`,
);
});
it("does not list all excludes when using common base", () => {
const common = createRerunSuggestion({
base: "common",
...getExclusions(options, "common"),
excludeLintKnip: undefined,
});
expect(common).toMatchInlineSnapshot(
`"npx create-typescript-app --base common"`,
);
});
it("does not list all excludes when using minimum base", () => {
const minimum = createRerunSuggestion({
base: "minimum",
...getExclusions(options, "minimum"),
excludeLintKnip: undefined,
});
expect(minimum).toMatchInlineSnapshot(
`"npx create-typescript-app --base minimum"`,
);
});
it("does not list API skip flags when --offline is true", () => {
const actual = createRerunSuggestion({
...options,
offline: true,
skipAllContributorsApi: true,
skipGitHubApi: true,
});
expect(actual).toMatchInlineSnapshot(
`"npx create-typescript-app --base everything --author TestAuthor --description "Test description." --directory . --email-github [email protected] --email-npm [email protected] --exclude-all-contributors --exclude-compliance --exclude-lint-jsdoc --exclude-lint-json --exclude-lint-knip --exclude-lint-package-json --exclude-lint-perfectionist --keywords "abc def ghi jkl mno pqr" --mode create --offline --owner TestOwner --repository test-repository --skip-install --skip-removal --title "Test Title""`,
);
});
});