all-contributors-cli/lib/generate/formatBadge.test.js
2016-03-07 00:28:25 +01:00

23 lines
946 B
JavaScript

import test from 'ava';
import _ from 'lodash/fp';
import formatBadge from './formatBadge';
test('should return badge with the number of contributors', t => {
const options = {};
const expected8 =
'[![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#contributors)';
const expected16 =
'[![All Contributors](https://img.shields.io/badge/all_contributors-16-orange.svg?style=flat-square)](#contributors)';
t.is(formatBadge(options, _.times(_.constant({}), 8)), expected8);
t.is(formatBadge(options, _.times(_.constant({}), 16)), expected16);
});
test('should be able to specify custom badge template', t => {
const options = {
badgeTemplate: 'We have <%= contributors.length %> contributors'
};
t.is(formatBadge(options, _.times(_.constant({}), 8)), 'We have 8 contributors');
t.is(formatBadge(options, _.times(_.constant({}), 16)), 'We have 16 contributors');
});