Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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 ✨

Expand All @@ -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
Expand All @@ -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
Expand Down
74 changes: 36 additions & 38 deletions src/init/__tests__/add-contributors-list.js
Original file line number Diff line number Diff line change
@@ -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)
})
})