@@ -3,50 +3,53 @@ import { date, number } from "./formats"
3
3
describe ( "@lingui/core/formats" , ( ) => {
4
4
describe ( "date" , ( ) => {
5
5
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" )
9
7
} )
10
8
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" )
14
10
} )
15
11
16
12
it ( "should pass format options" , ( ) => {
17
13
expect (
18
14
date ( [ "en" ] , new Date ( 2023 , 2 , 5 ) . toISOString ( ) , { dateStyle : "full" } )
19
- ) . toMatchInlineSnapshot ( ` "Sunday, March 5, 2023"` )
15
+ ) . toBe ( "Sunday, March 5, 2023" )
20
16
21
17
expect (
22
18
date ( [ "en" ] , new Date ( 2023 , 2 , 5 ) . toISOString ( ) , {
23
19
dateStyle : "medium" ,
24
20
} )
25
- ) . toMatchInlineSnapshot ( ` "Mar 5, 2023"` )
21
+ ) . toBe ( "Mar 5, 2023" )
26
22
} )
27
23
28
24
it ( "should respect passed locale" , ( ) => {
29
25
expect (
30
26
date ( [ "pl" ] , new Date ( 2023 , 2 , 5 ) . toISOString ( ) , { dateStyle : "full" } )
31
- ) . toMatchInlineSnapshot ( ` "niedziela, 5 marca 2023"` )
27
+ ) . toBe ( "niedziela, 5 marca 2023" )
32
28
} )
33
29
} )
34
30
35
31
describe ( "number" , ( ) => {
36
32
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
+ )
40
36
41
- expect (
42
- number ( [ "en" ] , 1000 , { maximumSignificantDigits : 3 } )
43
- ) . toMatchInlineSnapshot ( `"1,000"` )
37
+ expect ( number ( [ "en" ] , 1000 , { maximumSignificantDigits : 3 } ) ) . toBe (
38
+ "1,000"
39
+ )
44
40
} )
45
41
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 €" )
47
50
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" )
50
53
} )
51
54
} )
52
55
} )
0 commit comments