Skip to content

Commit 3ec19bc

Browse files
committed
test: reduce dependence on exact webpack optmizations
1 parent 322f6ec commit 3ec19bc

File tree

1 file changed

+23
-1
lines changed
  • packages/angular_devkit/build_angular/src/builders/browser/specs

1 file changed

+23
-1
lines changed

Diff for: packages/angular_devkit/build_angular/src/builders/browser/specs/svg_spec.ts

+23-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,29 @@ describe('Browser Builder allow svg', () => {
5757
host.scopedSync().read(join(outputPath, 'main.js')),
5858
);
5959

60-
expect(content).toContain('ɵɵnamespaceSVG');
60+
// Extract the AppComponent template function.
61+
// Example function:
62+
// function AppComponent_Template(rf, ctx) {
63+
// if (rf & 1) {
64+
// _angular_core__WEBPACK_IMPORTED_MODULE_1__.ay();
65+
// _angular_core__WEBPACK_IMPORTED_MODULE_0__.dZ(0, "svg", 0)(1, "text", 1);
66+
// _angular_core__WEBPACK_IMPORTED_MODULE_0__.fH(2, "Hello World");
67+
// _angular_core__WEBPACK_IMPORTED_MODULE_0__.dY()();
68+
// }
69+
// }
70+
71+
const templateFnMatch = content.match(
72+
/function AppComponent_Template\(rf, ctx\)\s*\{[\s\n]*if \(rf & 1\) \{\n([\s\S]+?)\n[ ]*\}/,
73+
);
74+
expect(templateFnMatch).toBeDefined();
75+
const [, templateCreate] = templateFnMatch!;
76+
77+
const createLines = templateCreate.split('\n');
78+
// Zero argument function first - that'd be ɵɵnamespaceSVG.
79+
expect(createLines[0]).toMatch(/\b[^(]+\(\);$/);
80+
// Create element function second.
81+
expect(createLines[1]).toMatch(/\b[^(]+\(0, "svg", 0\)/);
82+
6183
expect(host.scopedSync().exists(normalize('dist/app.component.svg'))).toBe(
6284
false,
6385
'should not copy app.component.svg to dist',

0 commit comments

Comments
 (0)