Skip to content

Commit

Permalink
test(@angular-devkit/build-angular): change extractLicenses unit te…
Browse files Browse the repository at this point in the history
…st to use build harness

This change adds a unit tests for the browser builder's extractLicenses option using the builder test harness.
  • Loading branch information
alan-agius4 committed Jan 11, 2021
1 parent df897f0 commit a266f55
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 30 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* @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 { buildWebpackBrowser } from '../../index';
import { BASE_OPTIONS, BROWSER_BUILDER_INFO, describeBuilder } from '../setup';

describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
describe('Option: "extractLicenses"', () => {
it(`should generate '3rdpartylicenses.txt' when 'extractLicenses' is true`, async () => {
harness.useTarget('build', {
...BASE_OPTIONS,
extractLicenses: true,
});

const { result } = await harness.executeOnce();
expect(result?.success).toBe(true);
harness.expectFile('dist/3rdpartylicenses.txt').content.toContain('MIT');
});

it(`should not generate '3rdpartylicenses.txt' when 'extractLicenses' is false`, async () => {
harness.useTarget('build', {
...BASE_OPTIONS,
extractLicenses: false,
});

const { result } = await harness.executeOnce();
expect(result?.success).toBe(true);
harness.expectFile('dist/3rdpartylicenses.txt').toNotExist();
});

it(`should not generate '3rdpartylicenses.txt' when 'extractLicenses' is not set`, async () => {
harness.useTarget('build', {
...BASE_OPTIONS,
});

const { result } = await harness.executeOnce();
expect(result?.success).toBe(true);
harness.expectFile('dist/3rdpartylicenses.txt').toNotExist();
});
});
});

0 comments on commit a266f55

Please sign in to comment.