Total Complexity | 2 |
Complexity/F | 1 |
Lines of Code | 28 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 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)( |
||
|
|||
22 | 'Error status entity', |
||
23 | ({ description, error, expectedResult }) => { |
||
24 | it(description, () => { |
||
25 | expect(getStatusByError(error)).toEqual(expectedResult); |
||
26 | }); |
||
27 | } |
||
28 | ); |
||
29 |
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.