|
| 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/operators'; |
| 10 | +import { BUILD_TIMEOUT, buildWebpackBrowser } from '../../index'; |
| 11 | +import { BASE_OPTIONS, BROWSER_BUILDER_INFO, describeBuilder } from '../setup'; |
| 12 | + |
| 13 | +describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => { |
| 14 | + describe('Behavior: "index is updated during watch mode"', () => { |
| 15 | + it('index is watched in watch mode', async () => { |
| 16 | + harness.useTarget('build', { |
| 17 | + ...BASE_OPTIONS, |
| 18 | + watch: true, |
| 19 | + }); |
| 20 | + |
| 21 | + const buildCount = await harness |
| 22 | + .execute() |
| 23 | + .pipe( |
| 24 | + timeout(BUILD_TIMEOUT), |
| 25 | + concatMap(async ({ result }, index) => { |
| 26 | + expect(result?.success).toBe(true); |
| 27 | + |
| 28 | + switch (index) { |
| 29 | + case 0: { |
| 30 | + harness.expectFile('dist/index.html').content.toContain('HelloWorldApp'); |
| 31 | + harness.expectFile('dist/index.html').content.not.toContain('UpdatedPageTitle'); |
| 32 | + |
| 33 | + // Trigger rebuild |
| 34 | + await harness.modifyFile('src/index.html', (s) => |
| 35 | + s.replace('HelloWorldApp', 'UpdatedPageTitle'), |
| 36 | + ); |
| 37 | + break; |
| 38 | + } |
| 39 | + case 1: { |
| 40 | + harness.expectFile('dist/index.html').content.toContain('UpdatedPageTitle'); |
| 41 | + break; |
| 42 | + } |
| 43 | + } |
| 44 | + }), |
| 45 | + take(2), |
| 46 | + count(), |
| 47 | + ) |
| 48 | + .toPromise(); |
| 49 | + |
| 50 | + expect(buildCount).toBe(2); |
| 51 | + }); |
| 52 | + }); |
| 53 | +}); |
0 commit comments