@@ -6,9 +6,10 @@ import {
66
77test ( 'Custom function' , ( ) => {
88 const functions = {
9- custom : ( { source, locales : [ locale ] } , _opt , input ) => ( {
9+ custom : ( { dir , source, locales : [ locale ] } , _opt , input ) => ( {
1010 type : 'custom' ,
1111 source,
12+ dir : dir ?? 'auto' ,
1213 locale,
1314 toParts : ( ) => [
1415 { type : 'custom' , source, locale, value : `part:${ input } ` }
@@ -17,9 +18,11 @@ test('Custom function', () => {
1718 } )
1819 } satisfies MessageFunctions ;
1920 const mf = new MessageFormat ( 'en' , '{$var :custom}' , { functions } ) ;
20- expect ( mf . format ( { var : 42 } ) ) . toEqual ( 'str :42' ) ;
21+ expect ( mf . format ( { var : 42 } ) ) . toEqual ( '\u2068str :42\u2069 ' ) ;
2122 expect ( mf . formatToParts ( { var : 42 } ) ) . toEqual ( [
22- { type : 'custom' , source : '$var' , locale : 'en' , value : 'part:42' }
23+ { type : 'bidiIsolation' , value : '\u2068' } ,
24+ { type : 'custom' , source : '$var' , locale : 'en' , value : 'part:42' } ,
25+ { type : 'bidiIsolation' , value : '\u2069' }
2326 ] ) ;
2427} ) ;
2528
@@ -98,9 +101,11 @@ describe('Function return is not a MessageValue', () => {
98101 } satisfies MessageFunctions ;
99102 const mf = new MessageFormat ( 'en' , '{:fail}' , { functions } ) ;
100103 const onError = jest . fn ( ) ;
101- expect ( mf . format ( undefined , onError ) ) . toEqual ( '{:fail}' ) ;
104+ expect ( mf . format ( undefined , onError ) ) . toEqual ( '\u2068 {:fail}\u2069 ' ) ;
102105 expect ( mf . formatToParts ( undefined , onError ) ) . toEqual ( [
103- { type : 'fallback' , source : ':fail' }
106+ { type : 'bidiIsolation' , value : '\u2068' } ,
107+ { type : 'fallback' , source : ':fail' } ,
108+ { type : 'bidiIsolation' , value : '\u2069' }
104109 ] ) ;
105110 expect ( onError ) . toHaveBeenCalledTimes ( 2 ) ;
106111 } ) ;
@@ -111,9 +116,11 @@ describe('Function return is not a MessageValue', () => {
111116 } satisfies MessageFunctions ;
112117 const mf = new MessageFormat ( 'en' , '{42 :fail}' , { functions } ) ;
113118 const onError = jest . fn ( ) ;
114- expect ( mf . format ( undefined , onError ) ) . toEqual ( '{|42|}' ) ;
119+ expect ( mf . format ( undefined , onError ) ) . toEqual ( '\u2068 {|42|}\u2069 ' ) ;
115120 expect ( mf . formatToParts ( undefined , onError ) ) . toEqual ( [
116- { type : 'fallback' , source : '|42|' }
121+ { type : 'bidiIsolation' , value : '\u2068' } ,
122+ { type : 'fallback' , source : '|42|' } ,
123+ { type : 'bidiIsolation' , value : '\u2069' }
117124 ] ) ;
118125 expect ( onError ) . toHaveBeenCalledTimes ( 2 ) ;
119126 } ) ;
0 commit comments