-
-
Notifications
You must be signed in to change notification settings - Fork 399
/
cli-duplicates.spec.ts
118 lines (97 loc) · 4.68 KB
/
cli-duplicates.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import * as chai from 'chai';
import { temporaryDir, shell, pkg, exists, exec, read, shellAsync } from '../helpers';
const expect = chai.expect;
const tmp = temporaryDir();
describe('CLI duplicates support', () => {
const distFolder = tmp.name + '-duplicates';
before(done => {
tmp.create(distFolder);
let ls = shell('node', [
'./bin/index-cli.js',
'-p',
'./test/src/todomvc-ng2-duplicates/src/tsconfig.json',
'-d',
distFolder
]);
if (ls.stderr.toString() !== '') {
console.error(`shell error: ${ls.stderr.toString()}`);
done('error');
}
done();
});
after(() => tmp.clean(distFolder));
it('Todo class generated', () => {
const file = exists(distFolder + '/classes/Todo.html');
expect(file).to.be.true;
});
it('Todo-1 class generated', () => {
const file = exists(distFolder + '/classes/Todo-1.html');
expect(file).to.be.true;
});
it('Todo-2 class generated', () => {
const file = exists(distFolder + '/classes/Todo-2.html');
expect(file).to.be.true;
});
it('TimeInterface generated', () => {
const file = exists(distFolder + '/interfaces/TimeInterface.html');
expect(file).to.be.true;
});
it('TimeInterface-1 generated', () => {
const file = exists(distFolder + '/interfaces/TimeInterface-1.html');
expect(file).to.be.true;
});
it('EmptyService generated', () => {
const file = exists(distFolder + '/injectables/EmptyService.html');
expect(file).to.be.true;
});
it('EmptyService-1 generated', () => {
const file = exists(distFolder + '/injectables/EmptyService-1.html');
expect(file).to.be.true;
});
it('FirstUpperPipe generated', () => {
const file = exists(distFolder + '/pipes/FirstUpperPipe.html');
expect(file).to.be.true;
});
it('NoopInterceptor generated', () => {
const file = exists(distFolder + '/interceptors/NoopInterceptor.html');
expect(file).to.be.true;
});
it('NoopInterceptor-1 generated', () => {
const file = exists(distFolder + '/interceptors/NoopInterceptor-1.html');
expect(file).to.be.true;
});
it('EmptyComponent generated', () => {
const file = exists(distFolder + '/components/EmptyComponent.html');
expect(file).to.be.true;
});
it('EmptyComponent-1 generated', () => {
const file = exists(distFolder + '/components/EmptyComponent-1.html');
expect(file).to.be.true;
});
it('DoNothingDirective generated', () => {
const file = exists(distFolder + '/directives/DoNothingDirective.html');
expect(file).to.be.true;
});
it('DoNothingDirective-1 generated', () => {
const file = exists(distFolder + '/directives/DoNothingDirective-1.html');
expect(file).to.be.true;
});
it('should support component inside module', () => {
let file = read(distFolder + '/js/menu-wc.js');
file = file.replace(/components-links-module-ValidationDemoModule-([a-zA-Z0-9-])+/g, 'components-links-module-ValidationDemoModule');
expect(file).to.contain(`id="xs-components-links-module-ValidationDemoModule"\') + \'>\\n \\n <li class="link">\\n <a href="components/ValidationDemo.html" data-type="entity-link" data-context="sub-entity" data-context-id="modules">ValidationDemo</a>`);
});
it('should support component inside module with duplicate', () => {
let file = read(distFolder + '/js/menu-wc.js');
file = file.replace(/components-links-module-FooterModule-([a-zA-Z0-9-])+/g, 'components-links-module-FooterModule');
// tslint:disable-next-line:max-line-length
expect(file).to.contain(`id="xs-components-links-module-FooterModule"\') + \'>\\n \\n <li class="link">\\n <a href="components/FooterComponent-1.html" data-type="entity-link" data-context="sub-entity" data-context-id="modules">FooterComponent</a>`);
expect(file).to.contain(`<li class="link">\\n <a href="components/FooterComponent.html" data-type="entity-link">FooterComponent</a>`);
});
it('Injectable with multiple decorators should not appear twice', () => {
let file = exists(distFolder + '/injectables/MyService.html');
expect(file).to.be.true;
file = exists(distFolder + '/injectables/MyService-1.html');
expect(file).to.be.false;
});
});