|
| 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 | +}); |
0 commit comments