-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
59 lines (50 loc) · 2.16 KB
/
test.js
File metadata and controls
59 lines (50 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'use strict';
var uncacheModules = require('./index');
describe('uncacheModules(path)', function() {
it('throw an error when path is empty', function() {
expect(uncacheModules).toThrowError(TypeError);
})
it('not throw an error when path for modules not exists', function() {
var unloadNotExistsFolder = function() {
uncacheModules('path/not/exists');
};
expect(unloadNotExistsFolder).not.toThrow();
})
it('not throw an error when no modules loaded for path', function() {
var unloadNoModulesLoaded = function() {
uncacheModules('./fixtures');
};
expect(unloadNoModulesLoaded).not.toThrow();
})
it('not throw an error when unloading loaded modules', function() {
var unload = function() {
require('./fixtures/single')
uncacheModules('./fixtures');
};
expect(unload).not.toThrow();
})
it('module would be unloaded', function() {
var callCountBefore = require('./fixtures/single')();
uncacheModules('./fixtures');
var callCountAfter = require('./fixtures/single')();
expect(callCountBefore).toBe(callCountAfter);
})
it('submodule on same level would be unloaded', function() {
var callCountBefore = require('./fixtures/with-submodule-on-same-level')();
uncacheModules('./fixtures');
var callCountAfter = require('./fixtures/single')();
expect(callCountBefore).toBe(callCountAfter);
})
it('submodule in subfolder would be unload', function() {
var callCountBefore = require('./fixtures/with-submodule-in-subfolder')();
uncacheModules('./fixtures');
var callCountAfter = require('./fixtures/with-submodule-in-subfolder')();
expect(callCountBefore).toBe(callCountAfter);
})
it('submodule in parent folder would not be unload', function() {
var callCountBefore = require('./fixtures/parent/with-submodule-in-parent-folder')();
uncacheModules('./fixtures/parent');
var callCountAfter = require('./fixtures/submodule-in-parent')();
expect(callCountBefore).not.toBe(callCountAfter);
})
})