test/error.spec.js   A
last analyzed

Complexity

Total Complexity 5
Complexity/F 1

Size

Lines of Code 26
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 0
wmc 5
c 2
b 0
f 1
nc 1
mnd 0
bc 5
fnc 5
dl 0
loc 26
rs 10
bpm 1
cpm 1
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A error.spec.js ➔ ??? 0 4 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
});