mirror of
https://github.com/all-contributors/cli.git
synced 2025-01-10 05:56:29 +00:00
f99b4701d3
* Add alt text (description) on all emoji
Using markdown its possible to attach an alt text (really the title
attribute) on a link, where the value of the link is the the emoji. As
for the actual href, using #xxxxx lets you not mess with the navigation
assuming you have unique keys. In my example, I'm simply using the
emoji's key and github user name (i.e., `<emoji-username>`).
All emojis are links even if they don't have any real url attached.
For example, `[👀](#eyes-kevinjalbert "Reviewed Pull Requests")`
* Add kevinjalbert to all-contributorsrc
60 lines
2.6 KiB
JavaScript
60 lines
2.6 KiB
JavaScript
import test from 'ava';
|
|
import _ from 'lodash/fp';
|
|
import formatContributor from './format-contributor';
|
|
import contributors from './fixtures/contributors.json';
|
|
|
|
function fixtures() {
|
|
const options = {
|
|
projectOwner: 'jfmengels',
|
|
projectName: 'all-contributors-cli',
|
|
imageSize: 150
|
|
};
|
|
return {options};
|
|
}
|
|
|
|
test('should format a simple contributor', t => {
|
|
const contributor = _.assign(contributors.kentcdodds, {contributions: ['review']});
|
|
const {options} = fixtures();
|
|
|
|
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")';
|
|
|
|
t.is(formatContributor(options, contributor), expected);
|
|
});
|
|
|
|
test('should format contributor with complex contribution types', t => {
|
|
const contributor = contributors.kentcdodds;
|
|
const {options} = fixtures();
|
|
|
|
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")';
|
|
|
|
t.is(formatContributor(options, contributor), expected);
|
|
});
|
|
|
|
test('should format contributor using custom template', t => {
|
|
const contributor = contributors.kentcdodds;
|
|
const {options} = fixtures();
|
|
options.contributorTemplate = '<%= contributor.name %> is awesome!';
|
|
|
|
const expected = 'Kent C. Dodds is awesome!';
|
|
|
|
t.is(formatContributor(options, contributor), expected);
|
|
});
|
|
|
|
test('should default image size to 100', t => {
|
|
const contributor = _.assign(contributors.kentcdodds, {contributions: ['review']});
|
|
const {options} = fixtures();
|
|
delete options.imageSize;
|
|
|
|
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")';
|
|
|
|
t.is(formatContributor(options, contributor), expected);
|
|
});
|
|
|
|
test('should format contributor with pipes in their name', t => {
|
|
const contributor = contributors.pipey;
|
|
const {options} = fixtures();
|
|
|
|
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")';
|
|
|
|
t.is(formatContributor(options, contributor), expected);
|
|
});
|