@@ -4,31 +4,45 @@ import { registryView } from './RokuRegistryView';
44describe ( 'RegistryView' , ( ) => {
55 describe ( 'formatValues' , ( ) => {
66 it ( 'should convert json into an object with the correct values' , ( ) => {
7+ const inputValue = 1 ;
78 const input = {
8- a : ' {"b": 1}'
9+ a : ` {"b": ${ inputValue } }`
910 } ;
1011 const result = registryView . formatValues ( input ) ;
11- expect ( result . a . b ) . to . equal ( 1 ) ;
12+ expect ( result . a . b ) . to . equal ( inputValue ) ;
1213 } ) ;
1314
1415 it ( 'should correctly handle multiple levels' , ( ) => {
16+ const inputValue = 1 ;
1517 const input = {
1618 a : {
17- b : ' {"c": 1}'
19+ b : ` {"c": ${ inputValue } }`
1820 }
1921 } ;
2022 const result = registryView . formatValues ( input ) ;
21- expect ( result . a . b . c ) . to . equal ( 1 ) ;
23+ expect ( result . a . b . c ) . to . equal ( inputValue ) ;
2224 } ) ;
2325
24- it ( 'should return the incoming value if not JSON' , ( ) => {
26+ it ( 'should not try and convert strings that look like numbers into numbers' , ( ) => {
27+ const inputValue = '1' ;
2528 const input = {
2629 a : {
27- b : 1
30+ b : inputValue
2831 }
2932 } ;
3033 const result = registryView . formatValues ( input ) ;
31- expect ( result . a . b ) . to . equal ( input . a . b ) ;
34+ expect ( result . a . b ) . to . equal ( inputValue ) ;
35+ } ) ;
36+
37+ it ( 'should not try and convert strings that look like booleans into booleans' , ( ) => {
38+ const inputValue = 'true' ;
39+ const input = {
40+ a : {
41+ b : inputValue
42+ }
43+ } ;
44+ const result = registryView . formatValues ( input ) ;
45+ expect ( result . a . b ) . to . equal ( inputValue ) ;
3246 } ) ;
3347 } ) ;
3448} ) ;
0 commit comments