|
| 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