-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
38 lines (32 loc) · 824 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
27
28
29
30
31
32
33
34
35
36
37
38
const listen = require('test-listen');
const micro = require('micro');
const request = require('request-promise');
const test = require('ava');
const swotApi = require('.');
const app = micro(swotApi);
let url;
test.before(async () => {
url = await listen(app);
});
test('endpoint works with edu email', async t => {
const body = await request(url, { qs: { email: 'foo@mit.edu' }, json: true });
t.deepEqual(
body,
{
email: 'foo@mit.edu',
institution: 'Massachusetts Institute of Technology',
is_academic: true
}
);
});
test('endpoint works with non-edu email', async t => {
const body = await request(url, { qs: { email: 'foo@bar.com' }, json: true });
t.deepEqual(
body,
{
email: 'foo@bar.com',
institution: null,
is_academic: false
}
);
});