diff --git a/src/init/__tests__/__snapshots__/add-contributors-list.js.snap b/src/init/__tests__/__snapshots__/add-contributors-list.js.snap index c528a5a1..a873e690 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,7 +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`] = ` +exports[`addContributorsList create contributors section if it is absent 1`] = ` "# project Description @@ -34,7 +34,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[`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..ca430918 100644 --- a/src/init/__tests__/add-contributors-list.js +++ b/src/init/__tests__/add-contributors-list.js @@ -1,53 +1,51 @@ -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() -}) +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 it is absent', () => { - const content = ['# project', '', 'Description'].join('\n') - const result = addContributorsList(content) + test('create contributors section if it is absent', () => { + const content = ['# project', '', 'Description'].join('\n') + const result = addContributorsList(content) - expect(result).toMatchSnapshot() -}) + 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) }) })