-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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. 💖
- Loading branch information
1 parent
869c703
commit 54f0934
Showing
25 changed files
with
2,939 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
import { testBlock } from "create-testers"; | ||
import { describe, expect, it } from "vitest"; | ||
|
||
import { blockAllContributors } from "./blockAllContributors.js"; | ||
import { optionsBase } from "./options.fakes.js"; | ||
|
||
describe("blockAllContributors", () => { | ||
it("defaults contributors to [] when not provided", () => { | ||
const creation = testBlock(blockAllContributors, { options: optionsBase }); | ||
|
||
expect(creation).toMatchInlineSnapshot(` | ||
{ | ||
"addons": [ | ||
{ | ||
"addons": { | ||
"ignores": [ | ||
"/.all-contributorsrc", | ||
], | ||
}, | ||
"block": [Function], | ||
}, | ||
], | ||
"files": { | ||
".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"}", | ||
".github": { | ||
"workflows": { | ||
"contributors.yml": "jobs: | ||
contributors: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: ./.github/actions/prepare | ||
- env: | ||
GITHUB_TOKEN: \${{ secrets.ACCESS_TOKEN }} | ||
uses: JoshuaKGoldberg/[email protected] | ||
name: Contributors | ||
on: | ||
push: | ||
branches: | ||
- main | ||
", | ||
}, | ||
}, | ||
}, | ||
"scripts": [ | ||
{ | ||
"commands": [ | ||
"npx -y all-contributors-cli generate", | ||
"npx -y all-contributors-cli add test-owner code,content,docs,ideas,infra,maintenance,projectManagement,tool", | ||
], | ||
"phase": 2, | ||
}, | ||
], | ||
} | ||
`); | ||
}); | ||
|
||
it("includes contributors when not provided", () => { | ||
const creation = testBlock(blockAllContributors, { | ||
options: { | ||
...optionsBase, | ||
contributors: [ | ||
{ | ||
avatar_url: "https://avatars.githubusercontent.com/u/3335181?v=4", | ||
contributions: ["bug", "ideas"], | ||
login: "JoshuaKGoldberg", | ||
name: "Josh Goldberg", | ||
profile: "http://www.joshuakgoldberg.com", | ||
}, | ||
], | ||
}, | ||
}); | ||
|
||
expect(creation).toMatchInlineSnapshot(` | ||
{ | ||
"addons": [ | ||
{ | ||
"addons": { | ||
"ignores": [ | ||
"/.all-contributorsrc", | ||
], | ||
}, | ||
"block": [Function], | ||
}, | ||
], | ||
"files": { | ||
".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"}", | ||
".github": { | ||
"workflows": { | ||
"contributors.yml": "jobs: | ||
contributors: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: ./.github/actions/prepare | ||
- env: | ||
GITHUB_TOKEN: \${{ secrets.ACCESS_TOKEN }} | ||
uses: JoshuaKGoldberg/[email protected] | ||
name: Contributors | ||
on: | ||
push: | ||
branches: | ||
- main | ||
", | ||
}, | ||
}, | ||
}, | ||
"scripts": [ | ||
{ | ||
"commands": [ | ||
"npx -y all-contributors-cli generate", | ||
"npx -y all-contributors-cli add test-owner code,content,docs,ideas,infra,maintenance,projectManagement,tool", | ||
], | ||
"phase": 2, | ||
}, | ||
], | ||
} | ||
`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { testBlock } from "create-testers"; | ||
import { describe, expect, test } from "vitest"; | ||
|
||
import { blockAreTheTypesWrong } from "./blockAreTheTypesWrong.js"; | ||
import { optionsBase } from "./options.fakes.js"; | ||
|
||
describe("blockAreTheTypesWrong", () => { | ||
test("production", () => { | ||
const creation = testBlock(blockAreTheTypesWrong, { | ||
options: optionsBase, | ||
}); | ||
|
||
expect(creation).toMatchInlineSnapshot(` | ||
{ | ||
"addons": [ | ||
{ | ||
"addons": { | ||
"jobs": [ | ||
{ | ||
"name": "Are The Types Wrong?", | ||
"steps": [ | ||
{ | ||
"run": "npx --yes @arethetypeswrong/cli --pack . --ignore-rules cjs-resolves-to-esm", | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
"block": [Function], | ||
}, | ||
], | ||
} | ||
`); | ||
}); | ||
}); |
Oops, something went wrong.