Passed
Push — master ( 9423ce...f03429 )
by Dmytro
01:57
created

tests/utils/formatter/formatTime.test.js   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 34
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 21
mnd 0
bc 0
fnc 1
dl 0
loc 34
rs 10
bpm 0
cpm 1
noi 1
c 0
b 0
f 0
1
import { assert } from 'chai';
2
import { load } from '../../utils';
3
4
const { formatTime } = load('utils/formatters.js');
5
6
suite('formatTime');
7
8
test('Positive: formatTime', async function () {
9
    const day = 86_400_000;
0 ignored issues
show
Bug introduced by
The variable _400_000 seems to be never declared. If this is a global, consider adding a /** global: _400_000 */ comment.

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.

Loading history...
10
11
    assert.equal(
12
        formatTime(10 * 1000 + 5),
13
        '10s 5ms'
14
    );
15
    assert.equal(
16
        formatTime(2 * 60 * 60 * 1000 + 5 * 1000, 3),
17
        '2h 5s'
18
    );
19
20
    assert.equal(
21
        formatTime(1 * 60 * 60 * 1000 + 10 * 60 * 1000 + 5 * 1000, 3),
22
        '1h 10min 5s'
23
    );
24
25
    assert.equal(
26
        formatTime(7 * day + 12, 3),
27
        '7d'
28
    );
29
30
    assert.equal(
31
        formatTime(7 * day + 12, 4),
32
        '7d 12ms'
33
    );
34
});
35