|
| 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 { logging } from '@angular-devkit/core'; |
| 9 | +import { buildWebpackBrowser } from '../../index'; |
| 10 | +import { BASE_OPTIONS, BROWSER_BUILDER_INFO, describeBuilder } from '../setup'; |
| 11 | + |
| 12 | +describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => { |
| 13 | + describe('Option: "showCircularDependencies"', () => { |
| 14 | + beforeEach(async () => { |
| 15 | + // Add circular dependency |
| 16 | + await harness.appendToFile( |
| 17 | + 'src/app/app.component.ts', |
| 18 | + `import { AppModule } from './app.module'; console.log(AppModule);`, |
| 19 | + ); |
| 20 | + }); |
| 21 | + |
| 22 | + it('should show cyclic dependency warning when option is set to true', async () => { |
| 23 | + harness.useTarget('build', { |
| 24 | + ...BASE_OPTIONS, |
| 25 | + showCircularDependencies: true, |
| 26 | + }); |
| 27 | + |
| 28 | + const { result, logs } = await harness.executeOnce(); |
| 29 | + |
| 30 | + expect(result?.success).toBe(true); |
| 31 | + expect(logs).toContain( |
| 32 | + jasmine.objectContaining<logging.LogEntry>({ |
| 33 | + message: jasmine.stringMatching(/Circular dependency detected/), |
| 34 | + }), |
| 35 | + ); |
| 36 | + }); |
| 37 | + |
| 38 | + it('should not show cyclic dependency warning when option is set to false', async () => { |
| 39 | + harness.useTarget('build', { |
| 40 | + ...BASE_OPTIONS, |
| 41 | + showCircularDependencies: false, |
| 42 | + }); |
| 43 | + |
| 44 | + const { result, logs } = await harness.executeOnce(); |
| 45 | + |
| 46 | + expect(result?.success).toBe(true); |
| 47 | + expect(logs).not.toContain( |
| 48 | + jasmine.objectContaining<logging.LogEntry>({ |
| 49 | + message: jasmine.stringMatching(/Circular dependency detected/), |
| 50 | + }), |
| 51 | + ); |
| 52 | + }); |
| 53 | + |
| 54 | + it('should not show cyclic dependency warning when option is not present', async () => { |
| 55 | + harness.useTarget('build', { |
| 56 | + ...BASE_OPTIONS, |
| 57 | + }); |
| 58 | + |
| 59 | + const { result, logs } = await harness.executeOnce(); |
| 60 | + |
| 61 | + expect(result?.success).toBe(true); |
| 62 | + expect(logs).not.toContain( |
| 63 | + jasmine.objectContaining<logging.LogEntry>({ |
| 64 | + message: jasmine.stringMatching(/Circular dependency detected/), |
| 65 | + }), |
| 66 | + ); |
| 67 | + }); |
| 68 | + }); |
| 69 | +}); |
0 commit comments