Passed
Push — master ( 7fe328...eb4ada )
by
unknown
01:39
created

tests/utils/module.test.js   A

Complexity

Total Complexity 5
Complexity/F 1.25

Size

Lines of Code 45
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 28
mnd 1
bc 1
fnc 4
dl 0
loc 45
rs 10
bpm 0.25
cpm 1.25
noi 0
c 0
b 0
f 0
1
import { assert } from 'chai';
2
import { load } from '../utils';
3
4
const { PeerDependency } = load('utils/module');
5
6
suite('Utils: module');
7
8
test('Load not installed module', function () {
9
    const module = PeerDependency.load('not-installed-module');
10
11
    assert.instanceOf(module, PeerDependency.X);
12
    assert.instanceOf(module, Error);
13
    assert.include(module.toString(), "MISSING_PEER_DEPENDENCY: Cannot find module 'not-installed-module'");
14
});
15
16
test('Load installed module', function () {
17
    const module = PeerDependency.load('myrmidon');
18
19
    assert.exists(module);
20
    assert.isFunction(module.isFunction);
21
});
22
23
24
test('Check not installed module', function () {
25
    const module = PeerDependency.load('not-installed-module');
26
27
    try {
28
        PeerDependency.check(module);
29
        assert.fail('Expected to fail');
30
    } catch (error) {
31
        assert.notInstanceOf(error, PeerDependency.X);
32
        assert.instanceOf(error, Error);
33
        assert.equal(error.code, 'MODULE_NOT_FOUND');
34
        assert.include(error.toString(), "Error: Cannot find module 'not-installed-module'");
35
    }
36
});
37
38
39
test('Check installed module', function () {
40
    const module = PeerDependency.load('myrmidon');
41
42
    PeerDependency.check(module);
43
    assert.exists(module);
44
    assert.isFunction(module.isFunction);
45
});
46