@@ -3,50 +3,53 @@ import { date, number } from "./formats"
33describe ( "@lingui/core/formats" , ( ) => {
44 describe ( "date" , ( ) => {
55 it ( "should support Date as input" , ( ) => {
6- expect ( date ( [ "en" ] , new Date ( 2023 , 2 , 5 ) ) ) . toMatchInlineSnapshot (
7- `"3/5/2023"`
8- )
6+ expect ( date ( [ "en" ] , new Date ( 2023 , 2 , 5 ) ) ) . toBe ( "3/5/2023" )
97 } )
108 it ( "should support iso string as input" , ( ) => {
11- expect (
12- date ( [ "en" ] , new Date ( 2023 , 2 , 5 ) . toISOString ( ) )
13- ) . toMatchInlineSnapshot ( `"3/5/2023"` )
9+ expect ( date ( [ "en" ] , new Date ( 2023 , 2 , 5 ) . toISOString ( ) ) ) . toBe ( "3/5/2023" )
1410 } )
1511
1612 it ( "should pass format options" , ( ) => {
1713 expect (
1814 date ( [ "en" ] , new Date ( 2023 , 2 , 5 ) . toISOString ( ) , { dateStyle : "full" } )
19- ) . toMatchInlineSnapshot ( ` "Sunday, March 5, 2023"` )
15+ ) . toBe ( "Sunday, March 5, 2023" )
2016
2117 expect (
2218 date ( [ "en" ] , new Date ( 2023 , 2 , 5 ) . toISOString ( ) , {
2319 dateStyle : "medium" ,
2420 } )
25- ) . toMatchInlineSnapshot ( ` "Mar 5, 2023"` )
21+ ) . toBe ( "Mar 5, 2023" )
2622 } )
2723
2824 it ( "should respect passed locale" , ( ) => {
2925 expect (
3026 date ( [ "pl" ] , new Date ( 2023 , 2 , 5 ) . toISOString ( ) , { dateStyle : "full" } )
31- ) . toMatchInlineSnapshot ( ` "niedziela, 5 marca 2023"` )
27+ ) . toBe ( "niedziela, 5 marca 2023" )
3228 } )
3329 } )
3430
3531 describe ( "number" , ( ) => {
3632 it ( "should pass format options" , ( ) => {
37- expect (
38- number ( [ "en" ] , 1000 , { style : "currency" , currency : "EUR" } )
39- ) . toMatchInlineSnapshot ( `"€1,000.00"` )
33+ expect ( number ( [ "en" ] , 1000 , { style : "currency" , currency : "EUR" } ) ) . toBe (
34+ "€1,000.00"
35+ )
4036
41- expect (
42- number ( [ "en" ] , 1000 , { maximumSignificantDigits : 3 } )
43- ) . toMatchInlineSnapshot ( `"1,000"` )
37+ expect ( number ( [ "en" ] , 1000 , { maximumSignificantDigits : 3 } ) ) . toBe (
38+ "1,000"
39+ )
4440 } )
4541
46- it ( "should respect passed locale" , ( ) => {
42+ it ( "should respect passed locale(s)" , ( ) => {
43+ expect ( number ( [ "pl" ] , 1000 , { style : "currency" , currency : "EUR" } ) ) . toBe (
44+ "1000,00 €"
45+ )
46+
47+ expect (
48+ number ( [ "pl" , "en-US" ] , 1000 , { style : "currency" , currency : "EUR" } )
49+ ) . toBe ( "1000,00 €" )
4750 expect (
48- number ( [ "pl" ] , 1000 , { style : "currency" , currency : "EUR" } )
49- ) . toMatchInlineSnapshot ( `"1000,00 €"` )
51+ number ( [ "en-US" , " pl"] , 1000 , { style : "currency" , currency : "EUR" } )
52+ ) . toBe ( "€1,000.00" )
5053 } )
5154 } )
5255} )
0 commit comments