topics/capitalize/test.js   A
last analyzed

Complexity

Total Complexity 12
Complexity/F 1

Size

Lines of Code 53
Function Count 12

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 12
eloc 28
mnd 0
bc 0
fnc 12
dl 0
loc 53
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
1
const {
2
    capitalize,
3
    capitalize2
4
} = require('./index.js');
5
// put your tests here
6
test('test capitalize: normal case', () => {
7
    expect(capitalize('nguyen thanh nguyen')).toEqual('Nguyen Thanh Nguyen');
8
});
9
10
test('test capitalize: empty string', () => {
11
    expect(capitalize('')).toEqual('');
12
});
13
14
test('test capitalize: one-word string', () => {
15
    expect(capitalize('test')).toEqual('Test');
16
});
17
18
test('test capitalize: special character', () => {
19
    expect(capitalize('hey! i\'m here!')).toEqual('Hey! I\'m Here!');
20
});
21
22
test('test capitalize: test number', () => {
23
    expect(capitalize('hey! 123 n')).toEqual('Hey! 123 N');
24
});
25
26
test('test capitalize: test 2 space', () => {
27
    expect(capitalize('hey!  123')).toEqual('Hey!  123');
28
});
29
30
// test solution 2
31
test('test capitalize2: normal case', () => {
32
    expect(capitalize2('nguyen thanh nguyen')).toEqual('Nguyen Thanh Nguyen');
33
});
34
35
test('test capitalize2: empty string', () => {
36
    expect(capitalize2('')).toEqual('');
37
});
38
39
test('test capitalize2: one-word string', () => {
40
    expect(capitalize2('test')).toEqual('Test');
41
});
42
43
test('test capitalize2: special character', () => {
44
    expect(capitalize2('hey! i\'m here!')).toEqual('Hey! I\'m Here!');
45
});
46
47
test('test capitalize2: test number', () => {
48
    expect(capitalize2('hey! 123 n')).toEqual('Hey! 123 N');
49
});
50
51
test('test capitalize2: test 2 space', () => {
52
    expect(capitalize2('hey!  123')).toEqual('Hey!  123');
53
});