-
Notifications
You must be signed in to change notification settings - Fork 12k
/
Copy pathfind-lazy-module.spec.ts
50 lines (46 loc) · 1.47 KB
/
find-lazy-module.spec.ts
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
import * as mockFs from 'mock-fs';
import {stripIndents} from 'common-tags';
import {expect} from 'chai';
import {join} from 'path';
import {findLazyModules} from 'angular-cli/models/find-lazy-modules';
describe('find-lazy-module', () => {
beforeEach(() => {
mockFs({
'project-root': {
'fileA.ts': stripIndents`
const r1 = {
"loadChildren": "moduleA"
};
const r2 = {
loadChildren: "moduleB"
};
const r3 = {
'loadChildren': 'moduleC'
};
const r4 = {
"loadChildren": 'app/+workspace/+settings/settings.module#SettingsModule'
};
const r5 = {
loadChildren: 'unexistentModule'
};
`,
// Create those files too as they have to exist.
'moduleA.ts': '',
'moduleB.ts': '',
'moduleC.ts': '',
'moduleD.ts': '',
'app': { '+workspace': { '+settings': { 'settings.module.ts': '' } } }
}
});
});
afterEach(() => mockFs.restore());
it('works', () => {
expect(findLazyModules('project-root')).to.eql({
'moduleA': join(process.cwd(), 'project-root', 'moduleA.ts'),
'moduleB': join(process.cwd(), 'project-root', 'moduleB.ts'),
'moduleC': join(process.cwd(), 'project-root', 'moduleC.ts'),
'app/+workspace/+settings/settings.module':
join(process.cwd(), 'project-root', 'app/+workspace/+settings/settings.module.ts'),
});
});
});