Total Complexity | 2 |
Complexity/F | 1 |
Lines of Code | 29 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { expect, describe, it } from '@jest/globals'; |
||
2 | import getStatusByError from '../error-status.js'; |
||
3 | |||
4 | const TestCases = [ |
||
5 | { |
||
6 | description: 'A normal error should return status 500', |
||
7 | error: new Error('test'), |
||
8 | expectedResult: 500, |
||
9 | }, |
||
10 | { |
||
11 | description: 'A type error should return status 422', |
||
12 | error: new TypeError('test'), |
||
13 | expectedResult: 422, |
||
14 | }, |
||
15 | { |
||
16 | description: 'A range error should return status 404', |
||
17 | error: new RangeError('test'), |
||
18 | expectedResult: 404, |
||
19 | }, |
||
20 | ]; |
||
21 | |||
22 | describe.each(TestCases)( |
||
23 | 'Error status entity', |
||
24 | ({ description, error, expectedResult }) => { |
||
25 | it(description, () => { |
||
26 | expect(getStatusByError(error)).toEqual(expectedResult); |
||
27 | }); |
||
28 | } |
||
29 | ); |
||
30 |