@@ -30,7 +30,7 @@ describe('inputs with options', () => {
3030 test ( 'local variable with :number expression' , ( ) => {
3131 const mf = new MessageFormat (
3232 'en' ,
33- `.local $val = {12345678 :number useGrouping=false }
33+ `.local $val = {12345678 :number useGrouping=never }
3434 {{{$val :number minimumFractionDigits=2}}}`
3535 ) ;
3636 //const val = new MessageNumber(null, BigInt(12345678), { options: { useGrouping: false } });
@@ -77,20 +77,28 @@ describe('inputs with options', () => {
7777} ) ;
7878
7979describe ( 'Type casts based on runtime' , ( ) => {
80+ const date = '2000-01-01T15:00:00' ;
81+
8082 test ( 'boolean function option with literal value' , ( ) => {
81- const mfTrue = new MessageFormat ( 'en' , '{$var :number useGrouping=true}' ) ;
82- expect ( mfTrue . format ( { var : 1234 } ) ) . toBe ( '1,234' ) ;
83- const mfFalse = new MessageFormat ( 'en' , '{$var :number useGrouping=false}' ) ;
84- expect ( mfFalse . format ( { var : 1234 } ) ) . toBe ( '1234' ) ;
83+ const mfTrue = new MessageFormat (
84+ 'en' ,
85+ '{$date :datetime timeStyle=short hour12=true}'
86+ ) ;
87+ expect ( mfTrue . format ( { date } ) ) . toMatch ( / 3 : 0 0 / ) ;
88+ const mfFalse = new MessageFormat (
89+ 'en' ,
90+ '{$date :datetime timeStyle=short hour12=false}'
91+ ) ;
92+ expect ( mfFalse . format ( { date } ) ) . toMatch ( / 1 5 : 0 0 / ) ;
8593 } ) ;
8694
8795 test ( 'boolean function option with variable value' , ( ) => {
8896 const mf = new MessageFormat (
8997 'en' ,
90- '{$var :number useGrouping=$useGrouping }'
98+ '{$date :datetime timeStyle=short hour12=$hour12 }'
9199 ) ;
92- expect ( mf . format ( { var : 1234 , useGrouping : 'false' } ) ) . toBe ( '1234' ) ;
93- expect ( mf . format ( { var : 1234 , useGrouping : false } ) ) . toBe ( '1234' ) ;
100+ expect ( mf . format ( { date , hour12 : 'false' } ) ) . toMatch ( / 1 5 : 0 0 / ) ;
101+ expect ( mf . format ( { date , hour12 : false } ) ) . toMatch ( / 1 5 : 0 0 / ) ;
94102 } ) ;
95103} ) ;
96104
0 commit comments