2016-03-01 22:30:14 +00:00
|
|
|
import test from 'ava';
|
|
|
|
import _ from 'lodash/fp';
|
2016-05-05 14:27:26 +00:00
|
|
|
import formatContributor from './format-contributor';
|
2016-03-01 22:30:14 +00:00
|
|
|
import contributors from './fixtures/contributors.json';
|
|
|
|
|
|
|
|
function fixtures() {
|
|
|
|
const options = {
|
|
|
|
projectOwner: 'jfmengels',
|
|
|
|
projectName: 'all-contributors-cli',
|
2016-03-20 19:33:01 +00:00
|
|
|
imageSize: 150
|
2016-03-01 22:30:14 +00:00
|
|
|
};
|
|
|
|
return {options};
|
|
|
|
}
|
|
|
|
|
|
|
|
test('should format a simple contributor', t => {
|
2016-03-06 23:20:24 +00:00
|
|
|
const contributor = _.assign(contributors.kentcdodds, {contributions: ['review']});
|
2016-03-01 22:30:14 +00:00
|
|
|
const {options} = fixtures();
|
|
|
|
|
2017-04-15 14:15:31 +00:00
|
|
|
const expected = '[<img src="https://avatars1.githubusercontent.com/u/1500684" width="150px;"/><br /><sub>Kent C. Dodds</sub>](http://kentcdodds.com)<br />[👀](#review-kentcdodds "Reviewed Pull Requests")';
|
2016-03-01 22:30:14 +00:00
|
|
|
|
|
|
|
t.is(formatContributor(options, contributor), expected);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should format contributor with complex contribution types', t => {
|
|
|
|
const contributor = contributors.kentcdodds;
|
|
|
|
const {options} = fixtures();
|
|
|
|
|
2017-04-15 14:15:31 +00:00
|
|
|
const expected = '[<img src="https://avatars1.githubusercontent.com/u/1500684" width="150px;"/><br /><sub>Kent C. Dodds</sub>](http://kentcdodds.com)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds "Documentation") [👀](#review-kentcdodds "Reviewed Pull Requests") [💬](#question-kentcdodds "Answering Questions")';
|
2016-03-01 22:30:14 +00:00
|
|
|
|
|
|
|
t.is(formatContributor(options, contributor), expected);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should format contributor using custom template', t => {
|
|
|
|
const contributor = contributors.kentcdodds;
|
|
|
|
const {options} = fixtures();
|
2016-03-06 23:20:24 +00:00
|
|
|
options.contributorTemplate = '<%= contributor.name %> is awesome!';
|
2016-03-01 22:30:14 +00:00
|
|
|
|
|
|
|
const expected = 'Kent C. Dodds is awesome!';
|
|
|
|
|
|
|
|
t.is(formatContributor(options, contributor), expected);
|
|
|
|
});
|
|
|
|
|
2016-03-20 19:33:01 +00:00
|
|
|
test('should default image size to 100', t => {
|
2016-05-05 15:30:15 +00:00
|
|
|
const contributor = _.assign(contributors.kentcdodds, {contributions: ['review']});
|
2016-03-20 19:33:01 +00:00
|
|
|
const {options} = fixtures();
|
|
|
|
delete options.imageSize;
|
|
|
|
|
2017-04-15 14:15:31 +00:00
|
|
|
const expected = '[<img src="https://avatars1.githubusercontent.com/u/1500684" width="100px;"/><br /><sub>Kent C. Dodds</sub>](http://kentcdodds.com)<br />[👀](#review-kentcdodds "Reviewed Pull Requests")';
|
2016-05-05 15:30:15 +00:00
|
|
|
|
|
|
|
t.is(formatContributor(options, contributor), expected);
|
2016-03-01 22:30:14 +00:00
|
|
|
});
|
2017-04-07 13:52:55 +00:00
|
|
|
|
|
|
|
test('should format contributor with pipes in their name', t => {
|
|
|
|
const contributor = contributors.pipey;
|
|
|
|
const {options} = fixtures();
|
|
|
|
|
2017-04-15 14:15:31 +00:00
|
|
|
const expected = '[<img src="https://avatars1.githubusercontent.com/u/1500684" width="150px;"/><br /><sub>Who | Needs | Pipes?</sub>](http://github.com/chrisinajar)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=pipey "Documentation")';
|
2017-04-07 13:52:55 +00:00
|
|
|
|
|
|
|
t.is(formatContributor(options, contributor), expected);
|
|
|
|
});
|