2016-03-21 22:53:02 +00:00
|
|
|
import test from 'ava';
|
2016-05-05 14:27:26 +00:00
|
|
|
import {addContributorsList} from './init-content';
|
2016-03-21 22:53:02 +00:00
|
|
|
|
|
|
|
test('should insert list under contributors section', t => {
|
|
|
|
const content = [
|
|
|
|
'# project',
|
|
|
|
'',
|
|
|
|
'Description',
|
|
|
|
'',
|
|
|
|
'## Contributors',
|
|
|
|
''
|
|
|
|
].join('\n');
|
|
|
|
const expected = [
|
|
|
|
'# project',
|
|
|
|
'',
|
|
|
|
'Description',
|
|
|
|
'',
|
|
|
|
'## Contributors',
|
|
|
|
'',
|
|
|
|
'<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --><!-- ALL-CONTRIBUTORS-LIST:END -->'
|
|
|
|
].join('\n');
|
|
|
|
|
|
|
|
const result = addContributorsList(content);
|
|
|
|
|
|
|
|
t.is(result, expected);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should create contributors section if it is absent', t => {
|
|
|
|
const content = [
|
|
|
|
'# project',
|
|
|
|
'',
|
|
|
|
'Description'
|
|
|
|
].join('\n');
|
|
|
|
const expected = [
|
|
|
|
'# project',
|
|
|
|
'',
|
|
|
|
'Description',
|
|
|
|
'## Contributors',
|
|
|
|
'',
|
2016-05-11 18:08:01 +00:00
|
|
|
'Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):',
|
|
|
|
'',
|
|
|
|
'<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --><!-- ALL-CONTRIBUTORS-LIST:END -->',
|
|
|
|
'',
|
|
|
|
'This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!'
|
2016-03-21 22:53:02 +00:00
|
|
|
].join('\n');
|
|
|
|
|
|
|
|
const result = addContributorsList(content);
|
|
|
|
|
|
|
|
t.is(result, expected);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should create contributors section if content is empty', t => {
|
|
|
|
const content = '';
|
|
|
|
const expected = [
|
|
|
|
'',
|
|
|
|
'## Contributors',
|
|
|
|
'',
|
2016-05-11 18:08:01 +00:00
|
|
|
'Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):',
|
|
|
|
'',
|
|
|
|
'<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --><!-- ALL-CONTRIBUTORS-LIST:END -->',
|
|
|
|
'',
|
|
|
|
'This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!'
|
2016-03-21 22:53:02 +00:00
|
|
|
].join('\n');
|
|
|
|
|
|
|
|
const result = addContributorsList(content);
|
|
|
|
|
|
|
|
t.is(result, expected);
|
|
|
|
});
|