1
+ import * as localeSystem from "../../src/locale" ;
2
+
3
+ function run ( ) {
4
+ test ( 'Formatting with all arguments present and used' , ( ) => {
5
+ const string = 'The {adjective} {color} {animal} jumps over the lazy dog.' ;
6
+ const result = localeSystem . format ( string , {
7
+ adjective : 'smart' ,
8
+ color : 'blue' ,
9
+ animal : 'cat'
10
+ } ) ;
11
+ expect ( result ) . toEqual ( "The smart blue cat jumps over the lazy dog." )
12
+ } ) ;
13
+
14
+ test ( 'Formatting with some arguments used twice' , ( ) => {
15
+ const string = 'The {adjective} {color} {animal} jumps over the {adjective} dog.' ;
16
+ const result = localeSystem . format ( string , {
17
+ adjective : 'smart' ,
18
+ color : 'blue' ,
19
+ animal : 'cat'
20
+ } ) ;
21
+ expect ( result ) . toEqual ( "The smart blue cat jumps over the smart dog." )
22
+ } ) ;
23
+
24
+ test ( 'Formatting with some arguments not used' , ( ) => {
25
+ const string = 'The {adjective} brown {animal} jumps over the lazy dog.' ;
26
+ const result = localeSystem . format ( string , {
27
+ adjective : 'smart' ,
28
+ color : 'blue' ,
29
+ animal : 'cat'
30
+ } ) ;
31
+ expect ( result ) . toEqual ( "The smart brown cat jumps over the lazy dog." )
32
+ } ) ;
33
+
34
+ test ( 'Formatting with some arguments missing' , ( ) => {
35
+ const string = 'The {adjective} {color} {animal} jumps over the lazy dog.' ;
36
+ const result = localeSystem . format ( string , {
37
+ adjective : 'smart' ,
38
+ color : 'blue'
39
+ } ) ;
40
+ expect ( result ) . toEqual ( "The smart blue {animal} jumps over the lazy dog." )
41
+ } ) ;
42
+
43
+ test ( 'Formatting with some arguments having different casing' , ( ) => {
44
+ const string = 'The {aDjecTIVe} {Color} {animal} jumps over the lazy dog.' ;
45
+ const result = localeSystem . format ( string , {
46
+ AdJECtivE : 'smart' ,
47
+ color : 'blue' ,
48
+ Animal : 'cat'
49
+ } ) ;
50
+ expect ( result ) . toEqual ( "The smart blue cat jumps over the lazy dog." )
51
+ } ) ;
52
+ }
53
+
54
+ export default run ;
0 commit comments