refactor: return a Promise instead of relying on callback parameter (#289)

This commit is contained in:
Darek Kay 2020-10-04 22:11:18 +02:00 committed by GitHub
parent f1d576fda7
commit d44b70a1f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -30,20 +30,24 @@ test('create contributors section if content is empty', () => {
expect(result).toMatchSnapshot() expect(result).toMatchSnapshot()
}) })
test('README exists', done => { test('README exists', () => {
const file = 'README.md' return new Promise(done => {
ensureFileExists(file) const file = 'README.md'
.then(data => expect(data).toStrictEqual(file)) ensureFileExists(file)
.then(_ => done()) .then(data => expect(data).toStrictEqual(file))
.then(_ => done())
})
}) })
test("LOREM doesn't exists", done => { test("LOREM doesn't exists", () => {
const file = 'LOREM.md' return new Promise(done => {
ensureFileExists(file).then(data => { const file = 'LOREM.md'
expect(data).toStrictEqual(file) ensureFileExists(file).then(data => {
return unlink(file, err => { expect(data).toStrictEqual(file)
if (err) throw err return unlink(file, err => {
done() if (err) throw err
done()
})
}) })
}) })
}) })