tests/unit/utils.test.js   A
last analyzed

Complexity

Total Complexity 4
Complexity/F 1

Size

Lines of Code 30
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 4
mnd 0
bc 0
fnc 4
bpm 0
cpm 1
noi 0
1
import { assert } from 'chai';
2
import { testFunction } from '../utils';
3
import {
4
    cleanUndefined,
5
    mergeConfigs
6
} from '../../src/utils';
7
8
suite('Utils');
9
10
test('cleanUndefined', function () {
11
    const verify = testFunction(cleanUndefined);
12
13
    verify({}, {});
14
    verify({ a: 1, b: 2 }, { a: 1, b: 2 });
15
    verify({ a: null }, { a: null });
16
    verify({ a: 1, b: 2, c: null, d: undefined }, { a: 1, b: 2, c: null });
17
});
18
19
test('mergeConfigs', function () {
20
    const config = mergeConfigs(
21
        [ { logger: console, contextSanitizer: () => 1 } ],
22
        [],
23
        [ { level: 'info', contextSanitizer: () => 2 } ]
24
    );
25
26
    assert.isObject(config);
27
28
    assert.equal(config.level, 'info');
29
    assert.equal(config.contextSanitizer(), 1);
30
});
31