forked from blackbaud/skyux-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskyux-build-aot.e2e-spec.js
126 lines (103 loc) · 3.75 KB
/
skyux-build-aot.e2e-spec.js
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
119
120
121
122
123
124
125
126
/*jshint jasmine: true, node: true */
'use strict';
const common = require('./shared/common');
const tests = require('./shared/tests');
function prepareBuild() {
const opts = { mode: 'easy', name: 'dist', compileMode: 'aot' };
return common.prepareBuild(opts)
.catch(console.error);
}
describe('skyux build aot', () => {
describe('w/base template', () => {
beforeAll((done) => prepareBuild().then(done));
it('should have exitCode 0', tests.verifyExitCode);
it('should generate expected static files', tests.verifyFiles);
it('should render the home components', tests.renderHomeComponent);
it('should render shared nav component', tests.renderSharedNavComponent);
it('should follow routerLink and render about component', tests.followRouterLinkRenderAbout);
afterAll(common.afterAll);
});
describe('w/guard', () => {
beforeAll((done) => {
const guard = `
import { Injectable } from '@angular/core';
@Injectable()
export class AboutGuard {
canActivate(next: any, state: any) {
return false;
}
}
`;
common.writeAppFile('about/index.guard.ts', guard)
.then(() => prepareBuild())
.then(done)
.catch(console.error);
});
it('should not follow routerLink when guard returns false', tests.respectGuardCanActivate);
afterAll((done) => {
common.removeAppFile('about/index.guard.ts')
.then(() => common.afterAll())
.then(done)
.catch(console.error);
});
});
describe('w/root level guard', () => {
beforeAll((done) => {
const guard = `
import { Injectable } from '@angular/core';
@Injectable()
export class RootGuard {
canActivateChild(next: any, state: any) {
return false;
}
}
`;
common.writeAppFile('index.guard.ts', guard)
.then(() => prepareBuild())
.then(done)
.catch(console.error);
});
it('should respect root guard', tests.respectRootGuard);
afterAll((done) => {
common.removeAppFile('index.guard.ts')
.then(() => common.afterAll())
.then(done)
.catch(console.error);
});
});
describe('w/child routes', () => {
beforeAll((done) => {
common.verifyAppFolder('test')
.then(() => common.writeAppFile('index.html', '<a id="test" routerLink="/test">Test</a>'))
.then(() => common.writeAppFile(
'test/index.html',
'<h1>Hi</h1>' +
'<a id="child" routerLink="/test/child">Child</a>' +
'<a id="top" routerLink="/test/child/top">Top</a>' +
'<router-outlet></router-outlet>')
)
.then(() => common.verifyAppFolder('test/#child'))
.then(() => common.writeAppFile('test/#child/index.html', '<div id="text">Child</div>'))
.then(() => common.verifyAppFolder('test/#child/top'))
.then(() => common.writeAppFile('test/#child/top/index.html', '<div id="text">Top</div>'))
.then(() => prepareBuild())
.then(done)
.catch(console.error);
});
it('should have working child route', tests.verifyChildRoute);
it('should have working nested child route', tests.verifyNestedChildRoute);
it('should have working top level route inside child route folder', tests.verifyNestedTopRoute);
afterAll((done) => {
common.removeAppFile('test/#child/top/index.html')
.then(() => common.writeAppFile('index.html', '<my-home></my-home>'))
.then(() => common.removeAppFile('test/#child/index.html'))
.then(() => common.removeAppFile('test/index.html'))
.then(() => common.removeAppFolder('test/#child/top'))
.then(() => common.removeAppFolder('test/#child'))
.then(() => common.removeAppFolder('test'))
.then(() => common.afterAll())
.then(done)
.catch(console.error);
});
});
});