@@ -88,6 +88,18 @@ describe('Serializer', () => {
8888 expect ( serializer . decode ( 'hello' ) ) . to . equal ( 'hello' ) ;
8989 } ) ;
9090
91+ it ( 'encodes date to ISO string' , ( ) => {
92+ expect ( serializer . encode ( new Date ( 1620666095891 ) ) ) . to . equal (
93+ '2021-05-10T17:01:35.891Z'
94+ ) ;
95+ } ) ;
96+
97+ it ( 'decodes date string without modifying it' , ( ) => {
98+ expect ( serializer . decode ( '2021-05-10T17:01:35.891Z' ) ) . to . equal (
99+ '2021-05-10T17:01:35.891Z'
100+ ) ;
101+ } ) ;
102+
91103 // TODO(klimt): Make this test more interesting once we have a complex type
92104 // that can be created in JavaScript.
93105 it ( 'encodes array' , ( ) => {
@@ -117,12 +129,14 @@ describe('Serializer', () => {
117129 serializer . encode ( {
118130 foo : 1 ,
119131 bar : 'hello' ,
120- baz : [ 1 , 2 , 3 ]
132+ baz : [ 1 , 2 , 3 ] ,
133+ date : new Date ( 1620666095891 )
121134 } )
122135 ) . to . deep . equal ( {
123136 foo : 1 ,
124137 bar : 'hello' ,
125- baz : [ 1 , 2 , 3 ]
138+ baz : [ 1 , 2 , 3 ] ,
139+ date : '2021-05-10T17:01:35.891Z'
126140 } ) ;
127141 } ) ;
128142
@@ -138,12 +152,14 @@ describe('Serializer', () => {
138152 value : '1099511627776' ,
139153 '@type' : 'type.googleapis.com/google.protobuf.Int64Value'
140154 }
141- ]
155+ ] ,
156+ date : '2021-05-10T17:01:35.891Z'
142157 } )
143158 ) . to . deep . equal ( {
144159 foo : 1 ,
145160 bar : 'hello' ,
146- baz : [ 1 , 2 , 1099511627776 ]
161+ baz : [ 1 , 2 , 1099511627776 ] ,
162+ date : '2021-05-10T17:01:35.891Z'
147163 } ) ;
148164 } ) ;
149165
0 commit comments