1- import { stringInterpolation } from "../index"
1+ import { stringInterpolation } from "../index" ;
22
33describe ( "stringInterpolation()" , ( ) => {
44 test ( "Empty" , ( ) => {
55 expect ( ( ) => {
66 stringInterpolation ( "" , {
77 world : "world" ,
8- } )
9- } ) . toThrow ( "Empty string" )
10- } )
8+ } ) ;
9+ } ) . toThrow ( "Empty string" ) ;
10+ } ) ;
1111 test ( "Incorrect variable count" , ( ) => {
1212 expect ( ( ) => {
1313 stringInterpolation ( "Hello {{world}}" , {
1414 world : "world with varialbe" ,
1515 extraVariable : "this is unnecessary" ,
16- } )
17- } ) . toThrow ( "Variable count mismatch" )
18- } )
16+ } ) ;
17+ } ) . toThrow ( "Variable count mismatch" ) ;
18+ } ) ;
1919 test ( "Variable not found" , ( ) => {
2020 expect ( ( ) =>
2121 stringInterpolation ( "Hello {{world}}" , {
2222 wrongVariable : "world" ,
2323 } )
24- ) . toThrow ( "Variable 'world' not found" )
25- } )
24+ ) . toThrow ( "Variable 'world' not found" ) ;
25+ } ) ;
2626 test ( "Interpolate single variable" , ( ) => {
2727 expect (
2828 stringInterpolation ( "Hello {{world}}" , {
2929 world : "world with variable" ,
3030 } )
31- ) . toBe ( "Hello world with variable" )
32- } )
31+ ) . toBe ( "Hello world with variable" ) ;
32+ } ) ;
3333 test ( "Interpolate single variable and return raw result with passed in option" , ( ) => {
3434 expect (
3535 stringInterpolation (
@@ -39,16 +39,16 @@ describe("stringInterpolation()", () => {
3939 } ,
4040 { raw : true }
4141 )
42- ) . toStrictEqual ( [ "Hello " , "world with variable" ] )
43- } )
42+ ) . toStrictEqual ( [ "Hello " , "world with variable" ] ) ;
43+ } ) ;
4444 test ( "Interpolate two variables" , ( ) => {
4545 expect (
4646 stringInterpolation ( "Hello {{world}} and {{anotherVariable}}" , {
4747 world : "world with variable" ,
4848 anotherVariable : "another variable" ,
4949 } )
50- ) . toBe ( "Hello world with variable and another variable" )
51- } )
50+ ) . toBe ( "Hello world with variable and another variable" ) ;
51+ } ) ;
5252 test ( "Interpolation variable contains a function" , ( ) => {
5353 expect (
5454 stringInterpolation ( "Hello {{world}} and {{anotherVariable}}" , {
@@ -60,6 +60,11 @@ describe("stringInterpolation()", () => {
6060 "world with variable" ,
6161 " and " ,
6262 expect . any ( Function ) ,
63- ] )
64- } )
65- } )
63+ ] ) ;
64+ } ) ;
65+ test ( "Interpolation string contains a variable name which should remain the same" , ( ) => {
66+ expect ( stringInterpolation ( "foo{{foo}}" , { foo : "bar" } ) ) . toStrictEqual (
67+ "foobar" // todo: fix - returns "barbar"
68+ ) ;
69+ } ) ;
70+ } ) ;
0 commit comments