|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright Google LLC 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 | + |
| 9 | +import { concatMap, count, take, timeout } from 'rxjs'; |
| 10 | +import { buildApplication } from '../../index'; |
| 11 | +import { APPLICATION_BUILDER_INFO, BASE_OPTIONS, describeBuilder } from '../setup'; |
| 12 | + |
| 13 | +describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => { |
| 14 | + describe('Behavior: "Rebuilds when touching file"', () => { |
| 15 | + for (const aot of [true, false]) { |
| 16 | + it(`Rebuild correctly when file is touched with ${aot ? 'AOT' : 'JIT'}`, async () => { |
| 17 | + harness.useTarget('build', { |
| 18 | + ...BASE_OPTIONS, |
| 19 | + watch: true, |
| 20 | + aot, |
| 21 | + }); |
| 22 | + |
| 23 | + const buildCount = await harness |
| 24 | + .execute({ outputLogsOnFailure: false }) |
| 25 | + .pipe( |
| 26 | + timeout(30_000), |
| 27 | + concatMap(async ({ result }, index) => { |
| 28 | + switch (index) { |
| 29 | + case 0: |
| 30 | + expect(result?.success).toBeTrue(); |
| 31 | + // Touch a file without doing any changes. |
| 32 | + await harness.modifyFile('src/app/app.component.ts', (content) => content); |
| 33 | + break; |
| 34 | + case 1: |
| 35 | + expect(result?.success).toBeTrue(); |
| 36 | + await harness.removeFile('src/app/app.component.ts'); |
| 37 | + break; |
| 38 | + case 2: |
| 39 | + expect(result?.success).toBeFalse(); |
| 40 | + break; |
| 41 | + } |
| 42 | + }), |
| 43 | + take(3), |
| 44 | + count(), |
| 45 | + ) |
| 46 | + .toPromise(); |
| 47 | + |
| 48 | + expect(buildCount).toBe(3); |
| 49 | + }); |
| 50 | + } |
| 51 | + }); |
| 52 | +}); |
0 commit comments