@@ -41,6 +41,33 @@ describe('Tea Util', function () {
4141 assert . deepStrictEqual ( Client . toJSONString ( { 'str' : 'test' , 'number' : 1 , 'bool' : false , 'null' : null } ) , '{"str":"test","number":1,"bool":false,"null":null}' ) ;
4242 } ) ;
4343
44+ it ( 'parseJSON should ok' , function ( ) {
45+ assert . deepStrictEqual ( Client . parseJSON ( '{}' ) , { } ) ;
46+ assert . deepStrictEqual ( Client . parseJSON ( '{"str":"test","number":1,"bool":false,"null":null}' ) , { 'str' : 'test' , 'number' : 1 , 'bool' : false , 'null' : null } ) ;
47+ assert . deepStrictEqual ( Client . parseJSON ( '[]' ) , [ ] ) ;
48+ assert . deepStrictEqual ( Client . parseJSON ( '1' ) , 1 ) ;
49+ assert . deepStrictEqual ( Client . parseJSON ( 'true' ) , true ) ;
50+ assert . deepStrictEqual ( Client . parseJSON ( 'null' ) , null ) ;
51+ } ) ;
52+
53+ it ( 'readPath should ok' , function ( ) {
54+ const context : Context = new Context ( {
55+ str : 'test' ,
56+ testBool : true ,
57+ contextInteger : 123 ,
58+ contextLong : 123 ,
59+ contextFloat : 3.456 ,
60+ contextDouble : 1.123 ,
61+ contextListLong : [ 123 , 456 ] ,
62+ listList : [ [ 123 , 456 ] , [ 789 , 123 ] ] ,
63+ integerListMap : {
64+ 'integerList' : [ 123 , 456 ] ,
65+ } ,
66+ } ) ;
67+
68+ assert . deepStrictEqual ( Client . readPath ( context , 'testStr' ) , 'test' ) ;
69+ } ) ;
70+
4471 it ( 'defaultString should ok' , function ( ) {
4572 assert . deepStrictEqual ( Client . defaultString ( '' , 'default' ) , 'default' ) ;
4673 assert . deepStrictEqual ( Client . defaultString ( 'input' , 'default' ) , 'input' ) ;
@@ -393,4 +420,4 @@ describe('Tea Util', function () {
393420 const result = Client . assertAsReadable ( readable ) ;
394421 assert . deepStrictEqual ( result , readable ) ;
395422 } ) ;
396- } ) ;
423+ } ) ;
0 commit comments