@@ -219,16 +219,17 @@ describe('JsonRpcServer', () => {
219219 } ) ;
220220 } ) ;
221221
222- it ( 'throws if passed a notification when only requests are supported' , async ( ) => {
222+ it ( 'errors if passed a notification when only requests are supported' , async ( ) => {
223223 const onError = jest . fn ( ) ;
224224 const server = new JsonRpcServer < JsonRpcMiddleware < JsonRpcRequest > > ( {
225225 middleware : [ ( ) => null ] ,
226226 onError,
227227 } ) ;
228228
229229 const notification = { jsonrpc, method : 'hello' } ;
230- await server . handle ( notification ) ;
230+ const response = await server . handle ( notification ) ;
231231
232+ expect ( response ) . toBeUndefined ( ) ;
232233 expect ( onError ) . toHaveBeenCalledTimes ( 1 ) ;
233234 expect ( onError ) . toHaveBeenCalledWith (
234235 new JsonRpcEngineError (
@@ -237,16 +238,25 @@ describe('JsonRpcServer', () => {
237238 ) ;
238239 } ) ;
239240
240- it ( 'throws if passed a request when only notifications are supported' , async ( ) => {
241+ it ( 'errors if passed a request when only notifications are supported' , async ( ) => {
241242 const onError = jest . fn ( ) ;
242243 const server = new JsonRpcServer < JsonRpcMiddleware < JsonRpcNotification > > ( {
243244 middleware : [ ( ) => undefined ] ,
244245 onError,
245246 } ) ;
246247
247248 const request = { jsonrpc, id : 1 , method : 'hello' } ;
248- await server . handle ( request ) ;
249+ const response = await server . handle ( request ) ;
249250
251+ expect ( response ) . toStrictEqual ( {
252+ jsonrpc,
253+ id : 1 ,
254+ error : {
255+ code : - 32603 ,
256+ message : expect . stringMatching ( / ^ N o t h i n g e n d e d r e q u e s t : / u) ,
257+ data : { cause : expect . any ( Object ) } ,
258+ } ,
259+ } ) ;
250260 expect ( onError ) . toHaveBeenCalledTimes ( 1 ) ;
251261 expect ( onError ) . toHaveBeenCalledWith (
252262 expect . objectContaining ( {
@@ -291,7 +301,7 @@ describe('JsonRpcServer', () => {
291301 { jsonrpc } ,
292302 { id : 1 } ,
293303 ] ) (
294- 'throws if the request is not minimally conformant' ,
304+ 'errors if the request is not minimally conformant' ,
295305 async ( malformedRequest ) => {
296306 const onError = jest . fn ( ) ;
297307 const server = new JsonRpcServer ( {
0 commit comments