Skip to content

Commit 54f0934

Browse files
test: fill in unit tests for most create Blocks (#1777)
## PR Checklist - [x] Addresses an existing open issue: fixes #1775 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md) were taken ## Overview Fills in a whole bunch of snapshot tests. Cleans up some unused code and fixes some hardcodings too. Nothing that actually impacts the output creation. 💖
1 parent 869c703 commit 54f0934

25 files changed

+2939
-49
lines changed

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@
4444
"@clack/prompts": "^0.8.2",
4545
"@prettier/sync": "^0.5.2",
4646
"chalk": "^5.3.0",
47-
"create": "0.1.0-alpha.5",
47+
"create": "0.1.0-alpha.6",
4848
"execa": "^9.5.1",
4949
"git-remote-origin-url": "^4.0.0",
5050
"git-url-parse": "^16.0.0",
51-
"input-from-file": "0.1.0-alpha.0",
52-
"input-from-file-json": "0.1.0-alpha.1",
51+
"input-from-file": "0.1.0-alpha.2",
52+
"input-from-file-json": "0.1.0-alpha.2",
5353
"js-yaml": "^4.1.0",
5454
"lazy-value": "^3.0.0",
5555
"npm-user": "^6.1.1",
@@ -82,7 +82,7 @@
8282
"all-contributors-cli": "6.26.1",
8383
"c8": "10.1.2",
8484
"console-fail-test": "0.5.0",
85-
"create-testers": "0.1.0-alpha.5",
85+
"create-testers": "0.1.0-alpha.6",
8686
"cspell": "8.16.1",
8787
"eslint": "9.16.0",
8888
"eslint-plugin-jsdoc": "50.6.0",

pnpm-lock.yaml

+38-27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import { testBlock } from "create-testers";
2+
import { describe, expect, it } from "vitest";
3+
4+
import { blockAllContributors } from "./blockAllContributors.js";
5+
import { optionsBase } from "./options.fakes.js";
6+
7+
describe("blockAllContributors", () => {
8+
it("defaults contributors to [] when not provided", () => {
9+
const creation = testBlock(blockAllContributors, { options: optionsBase });
10+
11+
expect(creation).toMatchInlineSnapshot(`
12+
{
13+
"addons": [
14+
{
15+
"addons": {
16+
"ignores": [
17+
"/.all-contributorsrc",
18+
],
19+
},
20+
"block": [Function],
21+
},
22+
],
23+
"files": {
24+
".all-contributorsrc": "{"badgeTemplate":"\\t<a href=\\"#contributors\\" target=\\"_blank\\"><img alt=\\"👪 All Contributors: <%= contributors.length %>\\" src=\\"https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-<%= contributors.length %>-21bb42.svg\\" /></a>","commit":false,"commitConvention":"angular","commitType":"docs","contributors":[],"contributorsPerLine":7,"contributorsSortAlphabetically":true,"files":["README.md"],"imageSize":100,"projectName":"test-repository","projectOwner":"test-owner","repoHost":"https://github.com","repoType":"github"}",
25+
".github": {
26+
"workflows": {
27+
"contributors.yml": "jobs:
28+
contributors:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
- uses: ./.github/actions/prepare
35+
- env:
36+
GITHUB_TOKEN: \${{ secrets.ACCESS_TOKEN }}
37+
uses: JoshuaKGoldberg/[email protected]
38+
39+
name: Contributors
40+
41+
on:
42+
push:
43+
branches:
44+
- main
45+
",
46+
},
47+
},
48+
},
49+
"scripts": [
50+
{
51+
"commands": [
52+
"npx -y all-contributors-cli generate",
53+
"npx -y all-contributors-cli add test-owner code,content,docs,ideas,infra,maintenance,projectManagement,tool",
54+
],
55+
"phase": 2,
56+
},
57+
],
58+
}
59+
`);
60+
});
61+
62+
it("includes contributors when not provided", () => {
63+
const creation = testBlock(blockAllContributors, {
64+
options: {
65+
...optionsBase,
66+
contributors: [
67+
{
68+
avatar_url: "https://avatars.githubusercontent.com/u/3335181?v=4",
69+
contributions: ["bug", "ideas"],
70+
login: "JoshuaKGoldberg",
71+
name: "Josh Goldberg",
72+
profile: "http://www.joshuakgoldberg.com",
73+
},
74+
],
75+
},
76+
});
77+
78+
expect(creation).toMatchInlineSnapshot(`
79+
{
80+
"addons": [
81+
{
82+
"addons": {
83+
"ignores": [
84+
"/.all-contributorsrc",
85+
],
86+
},
87+
"block": [Function],
88+
},
89+
],
90+
"files": {
91+
".all-contributorsrc": "{"badgeTemplate":"\\t<a href=\\"#contributors\\" target=\\"_blank\\"><img alt=\\"👪 All Contributors: <%= contributors.length %>\\" src=\\"https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-<%= contributors.length %>-21bb42.svg\\" /></a>","commit":false,"commitConvention":"angular","commitType":"docs","contributors":[{"avatar_url":"https://avatars.githubusercontent.com/u/3335181?v=4","contributions":["bug","ideas"],"login":"JoshuaKGoldberg","name":"Josh Goldberg","profile":"http://www.joshuakgoldberg.com"}],"contributorsPerLine":7,"contributorsSortAlphabetically":true,"files":["README.md"],"imageSize":100,"projectName":"test-repository","projectOwner":"test-owner","repoHost":"https://github.com","repoType":"github"}",
92+
".github": {
93+
"workflows": {
94+
"contributors.yml": "jobs:
95+
contributors:
96+
runs-on: ubuntu-latest
97+
steps:
98+
- uses: actions/checkout@v4
99+
with:
100+
fetch-depth: 0
101+
- uses: ./.github/actions/prepare
102+
- env:
103+
GITHUB_TOKEN: \${{ secrets.ACCESS_TOKEN }}
104+
uses: JoshuaKGoldberg/[email protected]
105+
106+
name: Contributors
107+
108+
on:
109+
push:
110+
branches:
111+
- main
112+
",
113+
},
114+
},
115+
},
116+
"scripts": [
117+
{
118+
"commands": [
119+
"npx -y all-contributors-cli generate",
120+
"npx -y all-contributors-cli add test-owner code,content,docs,ideas,infra,maintenance,projectManagement,tool",
121+
],
122+
"phase": 2,
123+
},
124+
],
125+
}
126+
`);
127+
});
128+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { testBlock } from "create-testers";
2+
import { describe, expect, test } from "vitest";
3+
4+
import { blockAreTheTypesWrong } from "./blockAreTheTypesWrong.js";
5+
import { optionsBase } from "./options.fakes.js";
6+
7+
describe("blockAreTheTypesWrong", () => {
8+
test("production", () => {
9+
const creation = testBlock(blockAreTheTypesWrong, {
10+
options: optionsBase,
11+
});
12+
13+
expect(creation).toMatchInlineSnapshot(`
14+
{
15+
"addons": [
16+
{
17+
"addons": {
18+
"jobs": [
19+
{
20+
"name": "Are The Types Wrong?",
21+
"steps": [
22+
{
23+
"run": "npx --yes @arethetypeswrong/cli --pack . --ignore-rules cjs-resolves-to-esm",
24+
},
25+
],
26+
},
27+
],
28+
},
29+
"block": [Function],
30+
},
31+
],
32+
}
33+
`);
34+
});
35+
});

0 commit comments

Comments
 (0)