-
Notifications
You must be signed in to change notification settings - Fork 12k
/
Copy pathsvg_spec_large.ts
71 lines (59 loc) · 2.07 KB
/
svg_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
71
/**
* @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, normalize, virtualFs } from '@angular-devkit/core';
import { createArchitect, host, outputPath, veEnabled } from '../utils';
describe('Browser Builder allow svg', () => {
const target = { 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 with aot', async () => {
const svg = `
<svg xmlns="http://www.w3.org/2000/svg">
<text x="20" y="20" font-size="20" fill="red">Hello World</text>
</svg>`;
host.writeMultipleFiles({
'./src/app/app.component.svg': svg,
'./src/app/app.component.ts': `
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.svg',
styleUrls: []
})
export class AppComponent {
title = 'app';
}
`,
});
const overrides = { aot: true };
const run = await architect.scheduleTarget(target, overrides);
await expectAsync(run.result).toBeResolvedTo(jasmine.objectContaining({ success: true }));
const exists = host.scopedSync().exists(join(outputPath, 'main.js'));
expect(exists).toBe(true, '"main.js" should exist');
if (exists) {
const content = virtualFs.fileBufferToString(
host.scopedSync().read(join(outputPath, 'main.js')),
);
if (!veEnabled) {
expect(content).toContain('ɵɵnamespaceSVG');
} else {
expect(content).toContain('":svg:svg"');
}
expect(host.scopedSync().exists(normalize('dist/app.component.svg'))).toBe(
false,
'should not copy app.component.svg to dist',
);
}
await run.stop();
});
});