@@ -573,8 +573,8 @@ describe('IntlMessageFormat', function () {
573
573
it ( 'simple message' , function ( ) {
574
574
const mf = new IntlMessageFormat ( 'hello <b>world</b>' , 'en' ) ;
575
575
expect (
576
- mf . format < object > ( { b : str => ( { str } ) } )
577
- ) . toEqual ( [ 'hello ' , { str : 'world' } ] ) ;
576
+ mf . format < object > ( { b : parts => ( { parts } ) } )
577
+ ) . toEqual ( [ 'hello ' , { parts : [ 'world' ] } ] ) ;
578
578
} ) ;
579
579
it ( 'nested tag message' , function ( ) {
580
580
const mf = new IntlMessageFormat (
@@ -583,7 +583,7 @@ describe('IntlMessageFormat', function () {
583
583
) ;
584
584
expect (
585
585
mf . format < object > ( {
586
- b : ( ... chunks ) => ( { chunks} ) ,
586
+ b : chunks => ( { chunks} ) ,
587
587
i : c => ( { val : `$$${ c } $$` } ) ,
588
588
} )
589
589
) . toEqual ( [ 'hello ' , { chunks : [ 'world' , { val : '$$!$$' } , ' <br/> ' ] } ] ) ;
@@ -595,7 +595,7 @@ describe('IntlMessageFormat', function () {
595
595
) ;
596
596
expect (
597
597
mf . format < object > ( {
598
- b : ( ... chunks ) => [ '<b>' , ...chunks , '</b>' ] ,
598
+ b : chunks => [ '<b>' , ...chunks , '</b>' ] ,
599
599
i : c => ( { val : `$$${ c } $$` } ) ,
600
600
} )
601
601
) . toEqual ( [ 'hello <b>world' , { val : '$$!$$' } , ' <br/> </b>' ] ) ;
@@ -616,20 +616,20 @@ describe('IntlMessageFormat', function () {
616
616
) ;
617
617
expect (
618
618
mf . format < object > ( {
619
- b : str => ( { str } ) ,
619
+ b : parts => ( { parts } ) ,
620
620
placeholder : 'gaga' ,
621
- a : str => ( { str } ) ,
621
+ a : parts => ( { parts } ) ,
622
622
} )
623
- ) . toEqual ( [ 'hello ' , { str : 'world' } , ' ' , { str : 'gaga' } ] ) ;
623
+ ) . toEqual ( [ 'hello ' , { parts : [ 'world' ] } , ' ' , { parts : [ 'gaga' ] } ] ) ;
624
624
} ) ;
625
625
it ( 'message w/ placeholder & HTML entities' , function ( ) {
626
626
const mf = new IntlMessageFormat ( 'Hello<<tag>{text}</tag>' , 'en' ) ;
627
627
expect (
628
628
mf . format < object > ( {
629
- tag : str => ( { str } ) ,
629
+ tag : parts => ( { parts } ) ,
630
630
text : '<asd>' ,
631
631
} )
632
- ) . toEqual ( [ 'Hello<' , { str : '<asd>' } ] ) ;
632
+ ) . toEqual ( [ 'Hello<' , { parts : [ '<asd>' ] } ] ) ;
633
633
} ) ;
634
634
it ( 'message w/ placeholder & >' , function ( ) {
635
635
const mf = new IntlMessageFormat (
@@ -638,16 +638,16 @@ describe('IntlMessageFormat', function () {
638
638
) ;
639
639
expect (
640
640
mf . format < object > ( {
641
- b : str => ( { str } ) ,
641
+ b : parts => ( { parts } ) ,
642
642
token : '<asd>' ,
643
643
placeholder : '>' ,
644
- a : str => ( { str } ) ,
644
+ a : parts => ( { parts } ) ,
645
645
} )
646
646
) . toEqual ( [
647
647
'< hello ' ,
648
- { str : 'world' } ,
648
+ { parts : [ 'world' ] } ,
649
649
' <asd> <> ' ,
650
- { str : '>' } ,
650
+ { parts : [ '>' ] } ,
651
651
] ) ;
652
652
} ) ;
653
653
it ( 'select message w/ placeholder & >' , function ( ) {
@@ -665,16 +665,16 @@ describe('IntlMessageFormat', function () {
665
665
} )
666
666
) . toEqual ( [
667
667
'< hello ' ,
668
- { str : 'world' } ,
668
+ { str : [ 'world' ] } ,
669
669
' <asd> <> ' ,
670
- { str : '>' } ,
670
+ { str : [ '>' ] } ,
671
671
] ) ;
672
672
expect (
673
673
mf . format < object > ( {
674
674
gender : 'female' ,
675
675
b : str => ( { str} ) ,
676
676
} )
677
- ) . toEqual ( { str : 'foo <> bar' } ) ;
677
+ ) . toEqual ( { str : [ 'foo <> bar' ] } ) ;
678
678
} ) ;
679
679
it ( 'should allow escaping tag as legacy HTML' , function ( ) {
680
680
const mf = new IntlMessageFormat (
@@ -696,7 +696,7 @@ describe('IntlMessageFormat', function () {
696
696
} ) ,
697
697
bar : { bar : 1 } ,
698
698
} )
699
- ) . toEqual ( [ 'hello ' , { obj : { bar : 1 } } , ' test' ] ) ;
699
+ ) . toEqual ( [ 'hello ' , { obj : [ { bar : 1 } ] } , ' test' ] ) ;
700
700
} ) ;
701
701
it ( 'should handle tag in plural' , function ( ) {
702
702
const mf = new IntlMessageFormat (
@@ -705,7 +705,7 @@ describe('IntlMessageFormat', function () {
705
705
) ;
706
706
expect (
707
707
mf . format < string > ( {
708
- b : ( ... chunks ) => `{}${ chunks } {}` ,
708
+ b : chunks => `{}${ chunks } {}` ,
709
709
count : 1000 ,
710
710
} )
711
711
) . toBe ( 'You have {}1,000{} Messages' ) ;
0 commit comments