|
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
|
|
|
|