Skip to content

Commit 07cc9d5

Browse files
alan-agius4filipesilva
authored andcommitted
test(@angular-devkit/build-angular): change sri tests to use new test harness
(cherry picked from commit 3db8c6e)
1 parent 9d8b9a8 commit 07cc9d5

File tree

2 files changed

+50
-32
lines changed

2 files changed

+50
-32
lines changed

packages/angular_devkit/build_angular/src/browser/specs/subresource-integrity_spec.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
// tslint:disable:no-big-function
9+
import { logging } from '@angular-devkit/core';
10+
import { buildWebpackBrowser } from '../../index';
11+
import { BASE_OPTIONS, BROWSER_BUILDER_INFO, describeBuilder } from '../setup';
12+
13+
describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
14+
describe('Option: "subresourceIntegrity"', () => {
15+
it(`does not add integrity attribute when not present`, async () => {
16+
harness.useTarget('build', {
17+
...BASE_OPTIONS,
18+
});
19+
20+
const { result } = await harness.executeOnce();
21+
22+
expect(result?.success).toBe(true);
23+
harness.expectFile('dist/index.html').content.toContain('integrity=');
24+
});
25+
26+
it(`does not add integrity attribute when 'false'`, async () => {
27+
harness.useTarget('build', {
28+
...BASE_OPTIONS,
29+
subresourceIntegrity: false,
30+
});
31+
32+
const { result } = await harness.executeOnce();
33+
34+
expect(result?.success).toBe(true);
35+
harness.expectFile('dist/index.html').content.toContain('integrity=');
36+
});
37+
38+
it(`does add integrity attribute when 'true'`, async () => {
39+
harness.useTarget('build', {
40+
...BASE_OPTIONS,
41+
subresourceIntegrity: true,
42+
});
43+
44+
const { result } = await harness.executeOnce();
45+
46+
expect(result?.success).toBe(true);
47+
harness.expectFile('dist/index.html').content.toMatch(/integrity="\w+-[A-Za-z0-9\/\+=]+"/);
48+
});
49+
});
50+
});

0 commit comments

Comments
 (0)