Total Complexity | 5 |
Complexity/F | 1 |
Lines of Code | 26 |
Function Count | 5 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | import test from 'ava'; |
||
2 | import APIError from '../src/error'; |
||
3 | |||
4 | test.beforeEach(t => { |
||
5 | t.context.error = new APIError(404, 'Not Found', { body: 'body'}); |
||
6 | t.context.errorNoMessage = new APIError(404); |
||
7 | }); |
||
8 | |||
9 | test('instance of Error', t => { |
||
10 | t.true(t.context.error instanceof Error); |
||
11 | }); |
||
12 | |||
13 | test('instance of APIError', t => { |
||
14 | t.true(t.context.error instanceof APIError); |
||
15 | }); |
||
16 | |||
17 | test('to string', t => { |
||
18 | t.is(t.context.error.toString(), '404 - Not Found', 'has message'); |
||
19 | t.is(t.context.errorNoMessage.toString(), '404', 'No message'); |
||
20 | }); |
||
21 | |||
22 | test('has correct attributes', t => { |
||
23 | t.is(t.context.error.code, 404); |
||
24 | t.is(t.context.error.message, 'Not Found'); |
||
25 | t.deepEqual(t.context.error.body, { body: 'body'}); |
||
26 | }); |