|
8 | 8 | // tslint:disable:no-big-function
|
9 | 9 | import { Architect } from '@angular-devkit/architect';
|
10 | 10 | import { TestLogger } from '@angular-devkit/architect/testing';
|
11 |
| -import { logging, normalize, virtualFs } from '@angular-devkit/core'; |
| 11 | +import { join, logging, normalize, virtualFs } from '@angular-devkit/core'; |
12 | 12 | import { debounceTime, take, takeWhile, tap } from 'rxjs/operators';
|
13 | 13 | import {
|
14 | 14 | createArchitect,
|
15 | 15 | host,
|
16 | 16 | ivyEnabled,
|
17 | 17 | lazyModuleFiles,
|
18 | 18 | lazyModuleFnImport,
|
| 19 | + outputPath, |
19 | 20 | } from '../utils';
|
20 | 21 |
|
21 | 22 | describe('Browser Builder rebuilds', () => {
|
@@ -477,4 +478,64 @@ describe('Browser Builder rebuilds', () => {
|
477 | 478 | .toPromise();
|
478 | 479 | await run.stop();
|
479 | 480 | });
|
| 481 | + |
| 482 | + it('rebuilds AOT on CSS changes', async () => { |
| 483 | + const overrides = { watch: true, aot: true }; |
| 484 | + |
| 485 | + let buildCount = 1; |
| 486 | + const run = await architect.scheduleTarget(target, overrides); |
| 487 | + await run.output.pipe( |
| 488 | + debounceTime(1000), |
| 489 | + tap(() => { |
| 490 | + const content = virtualFs.fileBufferToString( |
| 491 | + host.scopedSync().read(join(outputPath, 'main.js')), |
| 492 | + ); |
| 493 | + |
| 494 | + switch (buildCount) { |
| 495 | + case 1: |
| 496 | + expect(content).not.toContain('color: green'); |
| 497 | + host.appendToFile('src/app/app.component.css', 'h1 { color: green; }'); |
| 498 | + break; |
| 499 | + case 2: |
| 500 | + expect(content).toContain('color: green'); |
| 501 | + break; |
| 502 | + } |
| 503 | + |
| 504 | + buildCount++; |
| 505 | + }), |
| 506 | + tap((buildEvent) => expect(buildEvent.success).toBe(true)), |
| 507 | + take(2), |
| 508 | + ).toPromise(); |
| 509 | + await run.stop(); |
| 510 | + }); |
| 511 | + |
| 512 | + it('rebuilds AOT on HTML changes', async () => { |
| 513 | + const overrides = { watch: true, aot: true }; |
| 514 | + |
| 515 | + let buildCount = 1; |
| 516 | + const run = await architect.scheduleTarget(target, overrides); |
| 517 | + await run.output.pipe( |
| 518 | + debounceTime(1000), |
| 519 | + tap(() => { |
| 520 | + const content = virtualFs.fileBufferToString( |
| 521 | + host.scopedSync().read(join(outputPath, 'main.js')), |
| 522 | + ); |
| 523 | + |
| 524 | + switch (buildCount) { |
| 525 | + case 1: |
| 526 | + expect(content).not.toContain('New Updated Content'); |
| 527 | + host.appendToFile('src/app/app.component.html', 'New Updated Content'); |
| 528 | + break; |
| 529 | + case 2: |
| 530 | + expect(content).toContain('New Updated Content'); |
| 531 | + break; |
| 532 | + } |
| 533 | + |
| 534 | + buildCount++; |
| 535 | + }), |
| 536 | + tap((buildEvent) => expect(buildEvent.success).toBe(true)), |
| 537 | + take(2), |
| 538 | + ).toPromise(); |
| 539 | + await run.stop(); |
| 540 | + }); |
480 | 541 | });
|
0 commit comments