Skip to content

Commit be96510

Browse files
petebacondarwinatscott
authored andcommitted
test(compiler): add additional i18n serialization tests (angular#38484)
The addiational tests check that ICUs containing interpolations are serialized correctly. PR Close angular#38484
1 parent cb05c01 commit be96510

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

packages/compiler/test/render3/view/i18n_spec.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ describe('serializeI18nMessageForLocalize', () => {
415415
});
416416

417417

418-
it('should serialize ICU with nested HTML for `$localize()`', () => {
418+
it('should serialize ICU with embedded HTML for `$localize()`', () => {
419419
expect(serialize('{age, plural, 10 {<b>ten</b>} other {<div class="A">other</div>}}')).toEqual({
420420
messageParts: [
421421
'{VAR_PLURAL, plural, 10 {{START_BOLD_TEXT}ten{CLOSE_BOLD_TEXT}} other {{START_TAG_DIV}other{CLOSE_TAG_DIV}}}'
@@ -424,6 +424,15 @@ describe('serializeI18nMessageForLocalize', () => {
424424
});
425425
});
426426

427+
it('should serialize ICU with embedded interpolation for `$localize()`', () => {
428+
expect(serialize('{age, plural, 10 {<b>ten</b>} other {{{age}} years old}}')).toEqual({
429+
messageParts: [
430+
'{VAR_PLURAL, plural, 10 {{START_BOLD_TEXT}ten{CLOSE_BOLD_TEXT}} other {{INTERPOLATION} years old}}'
431+
],
432+
placeHolders: []
433+
});
434+
});
435+
427436
it('should serialize ICU with nested HTML containing further ICUs for `$localize()`', () => {
428437
expect(
429438
serialize(
@@ -433,6 +442,18 @@ describe('serializeI18nMessageForLocalize', () => {
433442
placeHolders: ['ICU', 'START_TAG_DIV', 'ICU', 'CLOSE_TAG_DIV']
434443
});
435444
});
445+
446+
it('should serialize nested ICUs with embedded interpolation for `$localize()`', () => {
447+
expect(
448+
serialize(
449+
'{age, plural, 10 {ten {size, select, 1 {{{ varOne }}} 2 {{{ varTwo }}} other {2+}}} other {other}}'))
450+
.toEqual({
451+
messageParts: [
452+
'{VAR_PLURAL, plural, 10 {ten {VAR_SELECT, select, 1 {{INTERPOLATION}} 2 {{INTERPOLATION_1}} other {2+}}} other {other}}'
453+
],
454+
placeHolders: []
455+
});
456+
});
436457
});
437458

438459
describe('serializeIcuNode', () => {
@@ -447,7 +468,7 @@ describe('serializeIcuNode', () => {
447468
.toEqual('{VAR_PLURAL, plural, 10 {ten} other {other}}');
448469
});
449470

450-
it('should serialize a next ICU', () => {
471+
it('should serialize a nested ICU', () => {
451472
expect(serialize(
452473
'{age, plural, 10 {ten {size, select, 1 {one} 2 {two} other {2+}}} other {other}}'))
453474
.toEqual(
@@ -459,4 +480,9 @@ describe('serializeIcuNode', () => {
459480
.toEqual(
460481
'{VAR_PLURAL, plural, 10 {{START_BOLD_TEXT}ten{CLOSE_BOLD_TEXT}} other {{START_TAG_DIV}other{CLOSE_TAG_DIV}}}');
461482
});
483+
484+
it('should serialize an ICU with embedded interpolations', () => {
485+
expect(serialize('{age, select, 10 {ten} other {{{age}} years old}}'))
486+
.toEqual('{VAR_SELECT, select, 10 {ten} other {{INTERPOLATION} years old}}');
487+
});
462488
});

0 commit comments

Comments
 (0)