Skip to content

Commit dd7547d

Browse files
test: fill in coverage around blocks and utils
1 parent b1318b2 commit dd7547d

13 files changed

+315
-44
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"@vitest/coverage-v8": "3.0.7",
7979
"@vitest/eslint-plugin": "1.1.36",
8080
"all-contributors-cli": "6.26.1",
81-
"bingo-stratum-testers": "0.5.4",
81+
"bingo-stratum-testers": "0.5.5",
8282
"bingo-testers": "0.5.4",
8383
"console-fail-test": "0.5.0",
8484
"cspell": "8.17.5",

pnpm-lock.yaml

Lines changed: 16 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/blocks/blockCSpell.test.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,79 @@ describe("blockCSpell", () => {
144144
}
145145
`);
146146
});
147+
148+
test("setup mode", () => {
149+
const creation = testBlock(blockCSpell, {
150+
mode: "setup",
151+
options: optionsBase,
152+
});
153+
154+
expect(creation).toMatchInlineSnapshot(`
155+
{
156+
"addons": [
157+
{
158+
"addons": {
159+
"sections": {
160+
"Linting": {
161+
"contents": {
162+
"items": [
163+
"- \`pnpm lint:spelling\` ([cspell](https://cspell.org)): Spell checks across all source files",
164+
],
165+
},
166+
},
167+
},
168+
},
169+
"block": [Function],
170+
},
171+
{
172+
"addons": {
173+
"extensions": [
174+
"streetsidesoftware.code-spell-checker",
175+
],
176+
},
177+
"block": [Function],
178+
},
179+
{
180+
"addons": {
181+
"jobs": [
182+
{
183+
"name": "Lint Spelling",
184+
"steps": [
185+
{
186+
"run": "pnpm lint:spelling",
187+
},
188+
],
189+
},
190+
],
191+
},
192+
"block": [Function],
193+
},
194+
{
195+
"addons": {
196+
"properties": {
197+
"devDependencies": {
198+
"cspell": "8.17.5",
199+
},
200+
"scripts": {
201+
"lint:spelling": "cspell "**" ".github/**/*"",
202+
},
203+
},
204+
},
205+
"block": [Function],
206+
},
207+
],
208+
"files": {
209+
"cspell.json": "{"dictionaries":["npm","node","typescript"],"ignorePaths":[".github","CHANGELOG.md","lib","node_modules","pnpm-lock.yaml"]}",
210+
},
211+
"scripts": [
212+
{
213+
"commands": [
214+
"node path/to/cspell-populate-words/bin/index.mjs --words "access" --words "public" --words "description" --words "Test description" --words "directory" --words "." --words "email" --words "github" --words "[email protected]" --words "npm" --words "[email protected]" --words "owner" --words "test-owner" --words "repository" --words "test-repository" --words "title" --words "Test Title"",
215+
],
216+
"phase": 3,
217+
},
218+
],
219+
}
220+
`);
221+
});
147222
});

src/blocks/blockDevelopmentDocs.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,35 @@ describe("blockDevelopmentDocs", () => {
144144
`);
145145
});
146146

147+
test("with options.documentation", () => {
148+
const creation = testBlock(blockDevelopmentDocs, {
149+
options: {
150+
...optionsBase,
151+
documentation: "More documentation.",
152+
},
153+
});
154+
155+
expect(creation).toMatchInlineSnapshot(`
156+
{
157+
"files": {
158+
".github": {
159+
"DEVELOPMENT.md": "# Development
160+
161+
After [forking the repo from GitHub](https://help.github.com/articles/fork-a-repo) and [installing pnpm](https://pnpm.io/installation):
162+
163+
\`\`\`shell
164+
git clone https://github.com/(your-name-here)/test-repository
165+
cd test-repository
166+
pnpm install
167+
\`\`\`
168+
169+
More documentation.",
170+
},
171+
},
172+
}
173+
`);
174+
});
175+
147176
test("with options.guide", () => {
148177
const creation = testBlock(blockDevelopmentDocs, {
149178
options: {

src/blocks/blockESLint.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,13 @@ describe("blockESLint", () => {
284284
"b/d": ["error", { e: "f" }],
285285
},
286286
},
287+
{
288+
extends: ["c.configs.recommended"],
289+
rules: {
290+
"c/d": "error",
291+
"c/e": ["error", { f: "g" }],
292+
},
293+
},
287294
],
288295
ignores: ["generated"],
289296
imports: [
@@ -424,7 +431,7 @@ describe("blockESLint", () => {
424431
{ ignores: ["generated", "lib", "node_modules", "pnpm-lock.yaml"] },
425432
{ linterOptions: {"reportUnusedDisableDirectives":"error"} },
426433
eslint.configs.recommended,
427-
a.configs.recommended,{ extends: [b.configs.recommended], files: ["**/*.b"], rules: {"b/c":"error","b/d":["error",{"e":"f"}]}, },{ extends: [tseslint.configs.strictTypeChecked, tseslint.configs.stylisticTypeChecked], files: ["**/*.js", "**/*.ts"], languageOptions: {"parserOptions":{"projectService":{"allowDefaultProject":["*.config.*s"]},"tsconfigRootDir":import.meta.dirname}}, rules: {"a/b":"error","a/c":["error",{"d":"e"}]}, settings: {"react":{"version":"detect"}}, }
434+
a.configs.recommended,{ extends: [b.configs.recommended], files: ["**/*.b"], rules: {"b/c":"error","b/d":["error",{"e":"f"}]}, },{ extends: [c.configs.recommended], rules: {"c/d":"error","c/e":["error",{"f":"g"}]}, },{ extends: [tseslint.configs.strictTypeChecked, tseslint.configs.stylisticTypeChecked], files: ["**/*.js", "**/*.ts"], languageOptions: {"parserOptions":{"projectService":{"allowDefaultProject":["*.config.*s"]},"tsconfigRootDir":import.meta.dirname}}, rules: {"a/b":"error","a/c":["error",{"d":"e"}]}, settings: {"react":{"version":"detect"}}, }
428435
);",
429436
},
430437
"scripts": [

src/blocks/blockKnip.test.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,72 @@ describe("blockKnip", () => {
127127
}
128128
`);
129129
});
130+
131+
test("transition mode", () => {
132+
const creation = testBlock(blockKnip, {
133+
mode: "transition",
134+
options: optionsBase,
135+
});
136+
137+
expect(creation).toMatchInlineSnapshot(`
138+
{
139+
"addons": [
140+
{
141+
"addons": {
142+
"sections": {
143+
"Linting": {
144+
"contents": {
145+
"items": [
146+
"- \`pnpm lint:knip\` ([knip](https://github.com/webpro/knip)): Detects unused files, dependencies, and code exports",
147+
],
148+
},
149+
},
150+
},
151+
},
152+
"block": [Function],
153+
},
154+
{
155+
"addons": {
156+
"jobs": [
157+
{
158+
"name": "Lint Knip",
159+
"steps": [
160+
{
161+
"run": "pnpm lint:knip",
162+
},
163+
],
164+
},
165+
],
166+
},
167+
"block": [Function],
168+
},
169+
{
170+
"addons": {
171+
"properties": {
172+
"devDependencies": {
173+
"knip": "5.45.0",
174+
},
175+
"scripts": {
176+
"lint:knip": "knip",
177+
},
178+
},
179+
},
180+
"block": [Function],
181+
},
182+
],
183+
"files": {
184+
"knip.json": "{"$schema":"https://unpkg.com/[email protected]/schema.json","entry":["src/index.ts","src/**/*.test.*"],"ignoreExportsUsedInFile":{"interface":true,"type":true},"project":["src/**/*.ts"]}",
185+
},
186+
"scripts": [
187+
{
188+
"commands": [
189+
"rm .knip* knip.*",
190+
],
191+
"phase": 0,
192+
"silent": true,
193+
},
194+
],
195+
}
196+
`);
197+
});
130198
});

src/blocks/blockPackageJson.test.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,31 @@ describe("blockPackageJson", () => {
127127
`);
128128
});
129129

130+
test("with keywords", () => {
131+
const creation = testBlock(blockPackageJson, {
132+
options: {
133+
...options,
134+
keywords: ["abc", "def ghi"],
135+
},
136+
});
137+
138+
expect(creation).toMatchInlineSnapshot(`
139+
{
140+
"files": {
141+
"package.json": "{"name":"test-repository","version":"0.0.0","description":"A very very very very very very very very very very very very very very very very long HTML-ish description ending with an emoji. 🧵","keywords":["abc","def","ghi"],"repository":{"type":"git","url":"git+https://github.com/test-owner/test-repository.git"},"license":"MIT","author":{"email":"[email protected]"},"type":"module","main":"lib/index.js","files":["README.md","package.json"]}",
142+
},
143+
"scripts": [
144+
{
145+
"commands": [
146+
"pnpm install",
147+
],
148+
"phase": 1,
149+
},
150+
],
151+
}
152+
`);
153+
});
154+
130155
test("with node and pnpm versions", () => {
131156
const creation = testBlock(blockPackageJson, {
132157
options: {
@@ -154,4 +179,27 @@ describe("blockPackageJson", () => {
154179
}
155180
`);
156181
});
182+
183+
test("offline mode", () => {
184+
const creation = testBlock(blockPackageJson, {
185+
offline: true,
186+
options,
187+
});
188+
189+
expect(creation).toMatchInlineSnapshot(`
190+
{
191+
"files": {
192+
"package.json": "{"name":"test-repository","version":"0.0.0","description":"A very very very very very very very very very very very very very very very very long HTML-ish description ending with an emoji. 🧵","repository":{"type":"git","url":"git+https://github.com/test-owner/test-repository.git"},"license":"MIT","author":{"email":"[email protected]"},"type":"module","main":"lib/index.js","files":["README.md","package.json"]}",
193+
},
194+
"scripts": [
195+
{
196+
"commands": [
197+
"pnpm install --offline",
198+
],
199+
"phase": 1,
200+
},
201+
],
202+
}
203+
`);
204+
});
157205
});

src/blocks/blockRepositoryBranchRuleset.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe("blockRepositoryBranchRuleset", () => {
1414
});
1515

1616
// TODO for improving the "requests" snapshots:
17-
// https://github.com/JoshuaKGoldberg/create/issues/65
17+
// https://github.com/JoshuaKGoldberg/bingo/issues/65
1818

1919
test("without addons when mode is setup", () => {
2020
const creation = testBlock(blockRepositoryBranchRuleset, {
@@ -105,7 +105,7 @@ describe("blockRepositoryBranchRuleset", () => {
105105
`);
106106
});
107107

108-
test("with addons and a ruleset_id option when mode is transition", () => {
108+
test("with addons and a rulesetId option when mode is transition", () => {
109109
const creation = testBlock(blockRepositoryBranchRuleset, {
110110
addons: {
111111
requiredStatusChecks: ["build", "test"],

0 commit comments

Comments
 (0)