-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathtest.js
26 lines (20 loc) · 823 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import test from 'ava';
import githubUsername from './index.js';
test('gets GitHub username from email', async t => {
t.is(await githubUsername('sindresorhus@gmail.com'), 'sindresorhus');
});
test('gets GitHub username from email using Commit Search API', async t => {
t.is(await githubUsername('markdotto@gmail.com'), 'mdo');
});
test('rejects when GitHub has no user for the email', async t => {
await t.throwsAsync(githubUsername('nogithubaccount@example.com'));
});
test('rejects when email is missing', async t => {
await t.throwsAsync(githubUsername());
});
test('rejects when email is invalid', async t => {
await t.throwsAsync(githubUsername('sindresorhus_gmail.com'));
});
test('rejects when email is not a string', async t => {
await t.throwsAsync(githubUsername(() => 'sindresorhus_gmail.com'));
});