mirror of
https://github.com/all-contributors/cli.git
synced 2025-01-10 14:06:34 +00:00
1305a7cd92
BREAKING CHANGE: Drop support for Node < v4. This uses native Promises available from Node v4. * fix: Bump inquirer to v3.0.1. Fixes #33 to improve Windows support. * refactor: Promisify everything as inquirer uses Promises from 1.0.0 onwards
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
import test from 'ava';
|
|
import nock from 'nock';
|
|
import getUserInfo from './github';
|
|
|
|
test('should handle errors', t => {
|
|
nock('https://api.github.com')
|
|
.get('/users/nodisplayname')
|
|
.replyWithError(404);
|
|
|
|
return t.throws(getUserInfo('nodisplayname'));
|
|
});
|
|
|
|
test('should fill in the name when null is returned', t => {
|
|
nock('https://api.github.com')
|
|
.get('/users/nodisplayname')
|
|
.reply(200, {
|
|
login: 'nodisplayname',
|
|
name: null,
|
|
avatar_url: 'https://avatars2.githubusercontent.com/u/3869412?v=3&s=400',
|
|
html_url: 'https://github.com/nodisplayname'
|
|
});
|
|
|
|
return getUserInfo('nodisplayname')
|
|
.then(info => {
|
|
t.is(info.name, 'nodisplayname');
|
|
});
|
|
});
|
|
|
|
test('should fill in the name when an empty string is returned', t => {
|
|
nock('https://api.github.com')
|
|
.get('/users/nodisplayname')
|
|
.reply(200, {
|
|
login: 'nodisplayname',
|
|
name: '',
|
|
avatar_url: 'https://avatars2.githubusercontent.com/u/3869412?v=3&s=400',
|
|
html_url: 'https://github.com/nodisplayname'
|
|
});
|
|
|
|
return getUserInfo('nodisplayname')
|
|
.then(info => {
|
|
t.is(info.name, 'nodisplayname');
|
|
});
|
|
});
|