Passed
Branch main (d73254)
by Pieter Epeüs
24:57 queued 21:23
created

src/__tests__/error-status.unit.js   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 28
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 19
mnd 0
bc 0
fnc 2
dl 0
loc 28
rs 10
bpm 0
cpm 1
noi 1
c 0
b 0
f 0
1
import getStatusByError from '../error-status';
2
3
const TestCases = [
4
    {
5
        description: 'A normal error should return status 500',
6
        error: new Error('test'),
7
        expectedResult: 500,
8
    },
9
    {
10
        description: 'A type error should return status 422',
11
        error: new TypeError('test'),
12
        expectedResult: 422,
13
    },
14
    {
15
        description: 'A range error should return status 404',
16
        error: new RangeError('test'),
17
        expectedResult: 404,
18
    },
19
];
20
21
describe.each(TestCases)(
0 ignored issues
show
Bug introduced by
The variable describe seems to be never declared. If this is a global, consider adding a /** global: describe */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
22
    'Error status entity',
23
    ({ description, error, expectedResult }) => {
24
        it(description, () => {
25
            expect(getStatusByError(error)).toEqual(expectedResult);
26
        });
27
    }
28
);
29