Skip to content

Commit a266f55

Browse files
committed
test(@angular-devkit/build-angular): change extractLicenses unit test to use build harness
This change adds a unit tests for the browser builder's extractLicenses option using the builder test harness.
1 parent df897f0 commit a266f55

File tree

2 files changed

+45
-30
lines changed

2 files changed

+45
-30
lines changed

packages/angular_devkit/build_angular/src/browser/specs/license-extraction_spec.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
import { buildWebpackBrowser } from '../../index';
9+
import { BASE_OPTIONS, BROWSER_BUILDER_INFO, describeBuilder } from '../setup';
10+
11+
describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
12+
describe('Option: "extractLicenses"', () => {
13+
it(`should generate '3rdpartylicenses.txt' when 'extractLicenses' is true`, async () => {
14+
harness.useTarget('build', {
15+
...BASE_OPTIONS,
16+
extractLicenses: true,
17+
});
18+
19+
const { result } = await harness.executeOnce();
20+
expect(result?.success).toBe(true);
21+
harness.expectFile('dist/3rdpartylicenses.txt').content.toContain('MIT');
22+
});
23+
24+
it(`should not generate '3rdpartylicenses.txt' when 'extractLicenses' is false`, async () => {
25+
harness.useTarget('build', {
26+
...BASE_OPTIONS,
27+
extractLicenses: false,
28+
});
29+
30+
const { result } = await harness.executeOnce();
31+
expect(result?.success).toBe(true);
32+
harness.expectFile('dist/3rdpartylicenses.txt').toNotExist();
33+
});
34+
35+
it(`should not generate '3rdpartylicenses.txt' when 'extractLicenses' is not set`, async () => {
36+
harness.useTarget('build', {
37+
...BASE_OPTIONS,
38+
});
39+
40+
const { result } = await harness.executeOnce();
41+
expect(result?.success).toBe(true);
42+
harness.expectFile('dist/3rdpartylicenses.txt').toNotExist();
43+
});
44+
});
45+
});

0 commit comments

Comments
 (0)