@@ -174,6 +174,34 @@ module.exports = {
174174 expect ( decoded . result ) . to . equal ( 'Hello, World!' ) ;
175175 } ,
176176
177+ 'Simple synchronous echo with id as null' : function ( ) {
178+ var testJSON = '{ "method": "echo", "params": ["Hello, World!"], "id": null }' ;
179+ var req = new MockRequest ( 'POST' ) ;
180+ var res = new MockResponse ( ) ;
181+ server . handleHttp ( req , res ) ;
182+ req . emit ( 'data' , testJSON ) ;
183+ req . emit ( 'end' ) ;
184+ expect ( res . httpCode ) . to . equal ( 200 ) ;
185+ var decoded = JSON . parse ( res . httpBody ) ;
186+ expect ( decoded . id ) . to . equal ( null ) ;
187+ expect ( decoded . error ) . to . equal ( undefined ) ;
188+ expect ( decoded . result ) . to . equal ( 'Hello, World!' ) ;
189+ } ,
190+
191+ 'Simple synchronous echo with string as id' : function ( ) {
192+ var testJSON = '{ "method": "echo", "params": ["Hello, World!"], "id": "test" }' ;
193+ var req = new MockRequest ( 'POST' ) ;
194+ var res = new MockResponse ( ) ;
195+ server . handleHttp ( req , res ) ;
196+ req . emit ( 'data' , testJSON ) ;
197+ req . emit ( 'end' ) ;
198+ expect ( res . httpCode ) . to . equal ( 200 ) ;
199+ var decoded = JSON . parse ( res . httpBody ) ;
200+ expect ( decoded . id ) . to . equal ( 'test' ) ;
201+ expect ( decoded . error ) . to . equal ( undefined ) ;
202+ expect ( decoded . result ) . to . equal ( 'Hello, World!' ) ;
203+ } ,
204+
177205 'Using promise' : function ( ) {
178206 // Expose a function that just returns a promise that we can control.
179207 var callbackRef = null ;
0 commit comments