|
7 | 7 | */
|
8 | 8 |
|
9 | 9 | import { runTargetSpec } from '@angular-devkit/architect/testing';
|
10 |
| -import { join, normalize, virtualFs } from '@angular-devkit/core'; |
| 10 | +import { join, normalize, tags, virtualFs } from '@angular-devkit/core'; |
11 | 11 | import { tap } from 'rxjs/operators';
|
12 | 12 | import { browserTargetSpec, host } from '../utils';
|
13 | 13 |
|
@@ -35,4 +35,24 @@ describe('Browser Builder base href', () => {
|
35 | 35 | }),
|
36 | 36 | ).toPromise().then(done, done.fail);
|
37 | 37 | });
|
| 38 | + |
| 39 | + it('should insert base href in the the correct position', (done) => { |
| 40 | + host.writeMultipleFiles({ |
| 41 | + 'src/index.html': tags.oneLine` |
| 42 | + <html><head><meta charset="UTF-8"></head> |
| 43 | + <body><app-root></app-root></body></html> |
| 44 | + `, |
| 45 | + }); |
| 46 | + |
| 47 | + const overrides = { baseHref: '/myUrl' }; |
| 48 | + |
| 49 | + runTargetSpec(host, browserTargetSpec, overrides).pipe( |
| 50 | + tap((buildEvent) => expect(buildEvent.success).toBe(true)), |
| 51 | + tap(() => { |
| 52 | + const fileName = join(outputPath, 'index.html'); |
| 53 | + const content = virtualFs.fileBufferToString(host.scopedSync().read(fileName)); |
| 54 | + expect(content).toContain('<head><base href="/myUrl"><meta charset="UTF-8"></head>'); |
| 55 | + }), |
| 56 | + ).toPromise().then(done, done.fail); |
| 57 | + }); |
38 | 58 | });
|
0 commit comments