2016-03-21 22:53:02 +00:00
|
|
|
import test from 'ava';
|
|
|
|
import {addBadge} from './initContent';
|
|
|
|
|
|
|
|
test('should insert badge under title', t => {
|
|
|
|
const content = [
|
|
|
|
'# project',
|
|
|
|
'',
|
|
|
|
'Description',
|
|
|
|
'',
|
|
|
|
'Foo bar'
|
|
|
|
].join('\n');
|
|
|
|
const expected = [
|
|
|
|
'# project',
|
2016-03-22 18:53:10 +00:00
|
|
|
'[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors)',
|
2016-03-21 22:53:02 +00:00
|
|
|
'',
|
|
|
|
'Description',
|
|
|
|
'',
|
|
|
|
'Foo bar'
|
|
|
|
].join('\n');
|
|
|
|
|
|
|
|
const result = addBadge(content);
|
|
|
|
|
|
|
|
t.is(result, expected);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should add badge if content is empty', t => {
|
|
|
|
const content = '';
|
|
|
|
const expected = [
|
|
|
|
'',
|
2016-03-22 18:53:10 +00:00
|
|
|
'[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors)'
|
2016-03-21 22:53:02 +00:00
|
|
|
].join('\n');
|
|
|
|
|
|
|
|
const result = addBadge(content);
|
|
|
|
|
|
|
|
t.is(result, expected);
|
|
|
|
});
|