|
6 | 6 | * found in the LICENSE file at https://angular.dev/license |
7 | 7 | */ |
8 | 8 |
|
9 | | -/* eslint-disable max-len */ |
10 | 9 | import { concatMap, count, take, timeout } from 'rxjs'; |
11 | | -import { URL } from 'url'; |
12 | 10 | import { executeDevServer } from '../../index'; |
13 | 11 | import { describeServeBuilder } from '../jasmine-helpers'; |
14 | 12 | import { BASE_OPTIONS, BUILD_TIMEOUT, DEV_SERVER_BUILDER_INFO } from '../setup'; |
15 | 13 |
|
16 | | -describeServeBuilder( |
17 | | - executeDevServer, |
18 | | - DEV_SERVER_BUILDER_INFO, |
19 | | - (harness, setupTarget, isViteRun) => { |
20 | | - // TODO(fix-vite): currently this is broken in vite. |
21 | | - (isViteRun ? xdescribe : describe)( |
22 | | - 'Behavior: "i18n $localize calls are replaced during watching"', |
23 | | - () => { |
24 | | - beforeEach(() => { |
25 | | - harness.useProject('test', { |
26 | | - root: '.', |
27 | | - sourceRoot: 'src', |
28 | | - cli: { |
29 | | - cache: { |
30 | | - enabled: false, |
31 | | - }, |
32 | | - }, |
33 | | - i18n: { |
34 | | - sourceLocale: { |
35 | | - 'code': 'fr', |
36 | | - }, |
37 | | - }, |
38 | | - }); |
| 14 | +describeServeBuilder(executeDevServer, DEV_SERVER_BUILDER_INFO, (harness, setupTarget) => { |
| 15 | + describe('Behavior: "i18n $localize calls are replaced during watching"', () => { |
| 16 | + beforeEach(() => { |
| 17 | + harness.useProject('test', { |
| 18 | + root: '.', |
| 19 | + sourceRoot: 'src', |
| 20 | + cli: { |
| 21 | + cache: { |
| 22 | + enabled: false, |
| 23 | + }, |
| 24 | + }, |
| 25 | + i18n: { |
| 26 | + sourceLocale: { |
| 27 | + code: 'fr', |
| 28 | + }, |
| 29 | + }, |
| 30 | + }); |
39 | 31 |
|
40 | | - setupTarget(harness, { localize: ['fr'] }); |
41 | | - }); |
| 32 | + setupTarget(harness, { localize: ['fr'] }); |
| 33 | + }); |
42 | 34 |
|
43 | | - it('$localize are replaced in watch', async () => { |
44 | | - harness.useTarget('serve', { |
45 | | - ...BASE_OPTIONS, |
46 | | - watch: true, |
47 | | - }); |
| 35 | + it('$localize are replaced in watch', async () => { |
| 36 | + harness.useTarget('serve', { |
| 37 | + ...BASE_OPTIONS, |
| 38 | + watch: true, |
| 39 | + }); |
48 | 40 |
|
49 | | - await harness.writeFile( |
50 | | - 'src/app/app.component.html', |
51 | | - ` |
| 41 | + await harness.writeFile( |
| 42 | + 'src/app/app.component.html', |
| 43 | + ` |
52 | 44 | <p id="hello" i18n="An introduction header for this sample">Hello {{ title }}! </p> |
53 | 45 | `, |
54 | | - ); |
| 46 | + ); |
55 | 47 |
|
56 | | - const buildCount = await harness |
57 | | - .execute() |
58 | | - .pipe( |
59 | | - timeout(BUILD_TIMEOUT * 2), |
60 | | - concatMap(async ({ result }, index) => { |
61 | | - expect(result?.success).toBe(true); |
| 48 | + const buildCount = await harness |
| 49 | + .execute() |
| 50 | + .pipe( |
| 51 | + timeout(BUILD_TIMEOUT * 2), |
| 52 | + concatMap(async ({ result }, index) => { |
| 53 | + expect(result?.success).toBe(true); |
62 | 54 |
|
63 | | - const response = await fetch(new URL('main.js', `${result?.baseUrl}`)); |
64 | | - expect(await response?.text()).not.toContain('$localize`:'); |
| 55 | + const response = await fetch(new URL('main.js', `${result?.baseUrl}`)); |
| 56 | + expect(await response?.text()).not.toContain('$localize`:'); |
65 | 57 |
|
66 | | - switch (index) { |
67 | | - case 0: { |
68 | | - await harness.modifyFile('src/app/app.component.html', (content) => |
69 | | - content.replace('introduction', 'intro'), |
70 | | - ); |
71 | | - break; |
72 | | - } |
73 | | - } |
74 | | - }), |
75 | | - take(2), |
76 | | - count(), |
77 | | - ) |
78 | | - .toPromise(); |
| 58 | + switch (index) { |
| 59 | + case 0: { |
| 60 | + await harness.modifyFile('src/app/app.component.html', (content) => |
| 61 | + content.replace('introduction', 'intro'), |
| 62 | + ); |
| 63 | + break; |
| 64 | + } |
| 65 | + } |
| 66 | + }), |
| 67 | + take(2), |
| 68 | + count(), |
| 69 | + ) |
| 70 | + .toPromise(); |
79 | 71 |
|
80 | | - expect(buildCount).toBe(2); |
81 | | - }); |
82 | | - }, |
83 | | - ); |
84 | | - }, |
85 | | -); |
| 72 | + expect(buildCount).toBe(2); |
| 73 | + }); |
| 74 | + }); |
| 75 | +}); |
0 commit comments