Passed
Push — main ( 9d8971...cbde8c )
by Pieter Epeüs
05:09 queued 02:24
created

src/__tests__/string-helper.unit.js   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 35
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 25
mnd 0
bc 0
fnc 2
dl 0
loc 35
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
1
import { expect, describe, it } from '@jest/globals';
2
import { capitalizeWords } from '../string-helper.js';
3
4
const testCases = [
5
    {
6
        description: 'It should capitalize words',
7
        input: 'test',
8
        expectedResult: 'Test',
9
    },
10
    {
11
        description: 'It should capitalize "test_test_test"',
12
        input: 'test_test_test',
13
        expectedResult: 'TestTestTest',
14
    },
15
    {
16
        description: 'It should capitalize "test test test"',
17
        input: 'test test test',
18
        expectedResult: 'TestTestTest',
19
    },
20
    {
21
        description: 'It should capitalize "tEst teSt tesT"',
22
        input: 'tEst teSt tesT',
23
        expectedResult: 'TEstTeStTesT',
24
    },
25
];
26
27
describe.each(testCases)(
28
    'Test the item filter method',
29
    ({ description, input, expectedResult }) => {
30
        it(description, () => {
31
            const result = capitalizeWords(input);
32
            expect(result).toEqual(expectedResult);
33
        });
34
    }
35
);
36