Skip to content

Commit 365f1cb

Browse files
clydinalan-agius4
authored andcommitted
test(@angular/build): enable i18n localize watch test for dev-server
The existing test for i18n `$localize` replacement during watch mode has been re-enabled.
1 parent bfaa4d2 commit 365f1cb

File tree

1 file changed

+53
-63
lines changed

1 file changed

+53
-63
lines changed

packages/angular/build/src/builders/dev-server/tests/behavior/build_localize_replaced_watch_spec.ts

+53-63
Original file line numberDiff line numberDiff line change
@@ -6,80 +6,70 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
/* eslint-disable max-len */
109
import { concatMap, count, take, timeout } from 'rxjs';
11-
import { URL } from 'url';
1210
import { executeDevServer } from '../../index';
1311
import { describeServeBuilder } from '../jasmine-helpers';
1412
import { BASE_OPTIONS, BUILD_TIMEOUT, DEV_SERVER_BUILDER_INFO } from '../setup';
1513

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+
});
3931

40-
setupTarget(harness, { localize: ['fr'] });
41-
});
32+
setupTarget(harness, { localize: ['fr'] });
33+
});
4234

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+
});
4840

49-
await harness.writeFile(
50-
'src/app/app.component.html',
51-
`
41+
await harness.writeFile(
42+
'src/app/app.component.html',
43+
`
5244
<p id="hello" i18n="An introduction header for this sample">Hello {{ title }}! </p>
5345
`,
54-
);
46+
);
5547

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);
6254

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`:');
6557

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();
7971

80-
expect(buildCount).toBe(2);
81-
});
82-
},
83-
);
84-
},
85-
);
72+
expect(buildCount).toBe(2);
73+
});
74+
});
75+
});

0 commit comments

Comments
 (0)