forked from mitsuoka0423/line-notify-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.js
36 lines (31 loc) · 816 Bytes
/
index.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
describe('line-notify-nodejs', () => {
const mockAxios = require('axios');
jest.mock('axios');
test('Notify should be sent', async () => {
const target = require('./index')('token');
await target.notify({
message: 'message',
});
expect(mockAxios.post.mock.calls.length).toBe(1);
});
test('Token required error', () => {
const target = require('./index');
try {
target(null);
expect(1).toBe(2);
} catch (e) {
expect(e.message).toEqual('token is required');
}
});
test('Message required error', async () => {
const target = require('./index')('token');
try {
await target.notify({
message: null,
});
expect(1).toBe(2);
} catch (e) {
expect(e.message).toEqual('message is required');
}
});
});