src/__tests__/status-codes.unit.js   A
last analyzed

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 44
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 32
mnd 0
bc 0
fnc 2
dl 0
loc 44
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
1
import { expect, describe, it } from '@jest/globals';
2
import { isValid } from '../status-codes.js';
3
4
const TestCases = [
5
    {
6
        description: 'The statusCode 200 should be valid',
7
        statusCode: 200,
8
        expectedResult: true,
9
    },
10
    {
11
        description: 'The statusCode 201 should be valid',
12
        statusCode: 201,
13
        expectedResult: true,
14
    },
15
    {
16
        description: 'The statusCode 401 should be valid',
17
        statusCode: 401,
18
        expectedResult: true,
19
    },
20
    {
21
        description: 'The statusCode 404 should be valid',
22
        statusCode: 404,
23
        expectedResult: true,
24
    },
25
    {
26
        description: 'The statusCode 500 should be valid',
27
        statusCode: 500,
28
        expectedResult: true,
29
    },
30
    {
31
        description: 'The statusCode 123 should be invalid',
32
        statusCode: 123,
33
        expectedResult: false,
34
    },
35
];
36
37
describe.each(TestCases)(
38
    'Status codes helper',
39
    ({ description, statusCode, expectedResult }) => {
40
        it(description, () => {
41
            expect(isValid(statusCode)).toBe(expectedResult);
42
        });
43
    }
44
);
45