-
Notifications
You must be signed in to change notification settings - Fork 12k
/
Copy pathaot_spec_large.ts
70 lines (57 loc) · 2.09 KB
/
aot_spec_large.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
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { Architect } from '@angular-devkit/architect';
import { join, logging, normalize, virtualFs } from '@angular-devkit/core';
import { BrowserBuilderOutput } from '../../src/browser';
import { createArchitect, host, veEnabled } from '../utils';
describe('Browser Builder AOT', () => {
const targetSpec = { project: 'app', target: 'build' };
let architect: Architect;
beforeEach(async () => {
await host.initialize().toPromise();
architect = (await createArchitect(host.root())).architect;
});
afterEach(async () => host.restore().toPromise());
it('works', async () => {
const overrides = { aot: true };
const run = await architect.scheduleTarget(targetSpec, overrides);
const output = (await run.result) as BrowserBuilderOutput;
expect(output.success).toBe(true);
const fileName = join(normalize(output.outputPath), 'main.js');
const content = virtualFs.fileBufferToString(await host.read(normalize(fileName)).toPromise());
if (!veEnabled) {
expect(content).toContain('AppComponent.ɵcmp');
} else {
expect(content).toMatch(/platformBrowser.*bootstrapModuleFactory.*AppModuleNgFactory/);
}
await run.stop();
});
it('shows error when component stylesheet contains SCSS syntax error', async () => {
const overrides = {
aot: true,
};
host.replaceInFile(
'src/app/app.component.ts',
'app.component.css',
'app.component.scss',
);
host.writeMultipleFiles({
'src/app/app.component.scss': `
.foo {
`,
});
const logger = new logging.Logger('');
const logs: string[] = [];
logger.subscribe(e => logs.push(e.message));
const run = await architect.scheduleTarget(targetSpec, overrides, { logger });
const output = await run.result;
expect(output.success).toBe(false);
expect(logs.join()).toContain('SassError: expected "}".');
await run.stop();
});
});