From 48a1c0c382c18c902e777c1ecd7f8852b7633e13 Mon Sep 17 00:00:00 2001 From: Justin Dalrymple Date: Sat, 24 Jan 2026 13:55:31 -0500 Subject: [PATCH 1/3] test(add-contributors-list): improve the clarity of the tests and leverage async/await syntax --- .../add-contributors-list.js.snap | 22 +----- src/init/__tests__/add-contributors-list.js | 71 ++++++++----------- 2 files changed, 33 insertions(+), 60 deletions(-) diff --git a/src/init/__tests__/__snapshots__/add-contributors-list.js.snap b/src/init/__tests__/__snapshots__/add-contributors-list.js.snap index c528a5a1..874ddf46 100644 --- a/src/init/__tests__/__snapshots__/add-contributors-list.js.snap +++ b/src/init/__tests__/__snapshots__/add-contributors-list.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`create contributors section if content is empty 1`] = ` +exports[`addContributorsList create contributors section if content is empty 1`] = ` " ## Contributors ✨ @@ -16,25 +16,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!" `; -exports[`create contributors section if it is absent 1`] = ` -"# project - -Description -## Contributors ✨ - -Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): - - - - - - - - -This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!" -`; - -exports[`insert list under contributors section 1`] = ` +exports[`addContributorsList insert list under contributors section 1`] = ` "# project Description diff --git a/src/init/__tests__/add-contributors-list.js b/src/init/__tests__/add-contributors-list.js index bb532338..47e66557 100644 --- a/src/init/__tests__/add-contributors-list.js +++ b/src/init/__tests__/add-contributors-list.js @@ -1,53 +1,44 @@ -import {unlink} from 'fs' +import {unlink} from 'fs/promises' import {addContributorsList} from '../init-content' import ensureFileExists from '../file-exist' -test('insert list under contributors section', () => { - const content = [ - '# project', - '', - 'Description', - '', - '## Contributors', - '', - ].join('\n') - const result = addContributorsList(content) - - expect(result).toMatchSnapshot() -}) - -test('create contributors section if it is absent', () => { - const content = ['# project', '', 'Description'].join('\n') - const result = addContributorsList(content) - - expect(result).toMatchSnapshot() -}) +describe('addContributorsList', () => { + test('insert list under contributors section', () => { + const content = [ + '# project', + '', + 'Description', + '', + '## Contributors', + '', + ].join('\n') + const result = addContributorsList(content) + + expect(result).toMatchSnapshot() + }) -test('create contributors section if content is empty', () => { - const content = '' - const result = addContributorsList(content) + test('create contributors section if content is empty', () => { + const content = '' + const result = addContributorsList(content) - expect(result).toMatchSnapshot() + expect(result).toMatchSnapshot() + }) }) -test('README exists', () => { - return new Promise(done => { +describe('ensureFileExists', () => { + test('README exists', async () => { const file = 'README.md' - ensureFileExists(file) - .then(data => expect(data).toStrictEqual(file)) - .then(_ => done()) + const data = await ensureFileExists(file) + + expect(data).toStrictEqual(file) }) -}) -test("LOREM doesn't exists", () => { - return new Promise(done => { + test("LOREM doesn't exists", async () => { const file = 'LOREM.md' - ensureFileExists(file).then(data => { - expect(data).toStrictEqual(file) - return unlink(file, err => { - if (err) throw err - done() - }) - }) + const data = await ensureFileExists(file) + + expect(data).toStrictEqual(file) + + await unlink(file) }) }) From e8788f7ea8b4d883cf05181013d9b3f85d3c677d Mon Sep 17 00:00:00 2001 From: Justin Dalrymple Date: Sat, 24 Jan 2026 17:43:49 -0500 Subject: [PATCH 2/3] test: add missing test --- src/init/__tests__/add-contributors-list.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/init/__tests__/add-contributors-list.js b/src/init/__tests__/add-contributors-list.js index 47e66557..ca430918 100644 --- a/src/init/__tests__/add-contributors-list.js +++ b/src/init/__tests__/add-contributors-list.js @@ -17,6 +17,13 @@ describe('addContributorsList', () => { expect(result).toMatchSnapshot() }) + test('create contributors section if it is absent', () => { + const content = ['# project', '', 'Description'].join('\n') + const result = addContributorsList(content) + + expect(result).toMatchSnapshot() + }) + test('create contributors section if content is empty', () => { const content = '' const result = addContributorsList(content) From bdce486bd81032751a754ca26f4ca1db843e6a81 Mon Sep 17 00:00:00 2001 From: Justin Dalrymple Date: Sat, 24 Jan 2026 17:44:24 -0500 Subject: [PATCH 3/3] test: add missing snapshot --- .../add-contributors-list.js.snap | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/init/__tests__/__snapshots__/add-contributors-list.js.snap b/src/init/__tests__/__snapshots__/add-contributors-list.js.snap index 874ddf46..a873e690 100644 --- a/src/init/__tests__/__snapshots__/add-contributors-list.js.snap +++ b/src/init/__tests__/__snapshots__/add-contributors-list.js.snap @@ -16,6 +16,24 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!" `; +exports[`addContributorsList create contributors section if it is absent 1`] = ` +"# project + +Description +## Contributors ✨ + +Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): + + + + + + + + +This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!" +`; + exports[`addContributorsList insert list under contributors section 1`] = ` "# project