From e1943fa801d1b17490b4e4ff1a4b641d5f776901 Mon Sep 17 00:00:00 2001 From: Andrew Lisowski Date: Thu, 19 Mar 2020 13:41:23 -0700 Subject: [PATCH] add test --- .../__tests__/all-contributors.test.ts | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/plugins/all-contributors/__tests__/all-contributors.test.ts b/plugins/all-contributors/__tests__/all-contributors.test.ts index d35436308..a77c8394c 100644 --- a/plugins/all-contributors/__tests__/all-contributors.test.ts +++ b/plugins/all-contributors/__tests__/all-contributors.test.ts @@ -266,6 +266,42 @@ describe('All Contributors Plugin', () => { ); }); + test('should include sub-commit contributors', async () => { + const releasedLabel = new AllContributors(); + const autoHooks = makeHooks(); + mockRead( + '{ "contributors": [ { "login": "Jeff", "contributions": ["infra"] } ] }' + ); + + releasedLabel.apply({ hooks: autoHooks, logger: dummyLog() } as Auto.Auto); + + await autoHooks.afterAddToChangelog.promise({ + bump: Auto.SEMVER.patch, + currentVersion: '0.0.0', + lastRelease: '0.0.0', + releaseNotes: '', + commits: [ + { + subject: 'Do the thing', + hash: '123', + labels: [], + files: ['src/index.ts'], + authors: [ + { username: 'Jeff', hash: '123' }, + { username: 'Adam', hash: '456' } + ] + } + ] + }); + + expect(exec.mock.calls[0][0]).toBe( + 'npx all-contributors-cli add Jeff infra,code' + ); + expect(exec.mock.calls[1][0]).toBe( + 'npx all-contributors-cli add Adam code' + ); + }); + test('should not update if no new contribution types', async () => { const releasedLabel = new AllContributors(); const autoHooks = makeHooks();