-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
42 lines (36 loc) · 790 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
39
40
41
42
'use strict';
import test from 'ava';
import proxyquire from 'proxyquire';
const quire = proxyquire.noPreserveCache();
test.cb('handling missing thought', t => {
const app = quire('./index', {
got: function() {
return Promise.resolve({
body: null
});
}
});
app()
.then(() => {
t.fail();
t.end();
})
.catch((err) => {
t.is(err.message, 'Thought bubble is unavailable');
t.end();
});
});
test.cb('api test', t => {
const app = require('./index');
app()
.then((quote) => {
t.ok(quote.quote, 'quote is unavailable');
t.ok(quote.author, 'author is unavailable');
t.ok(quote.url, 'url is unavailable');
t.end();
})
.catch((err) => {
t.fail();
t.end();
});
});