all-contributors-cli/lib/init/add-badge.test.js

37 lines
817 B
JavaScript
Raw Normal View History

2016-03-21 22:53:02 +00:00
import test from 'ava';
2016-05-05 14:27:26 +00:00
import {addBadge} from './init-content';
2016-03-21 22:53:02 +00:00
test('should insert badge under title', t => {
const content = [
'# project',
'',
'Description',
'',
'Foo bar'
].join('\n');
const expected = [
'# project',
'[![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 = [
'',
'[![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);
});