@@ -214,7 +214,7 @@ describe('standardHandler', () => {
214214 } )
215215 } )
216216
217- it ( 'on error encoding failure, falls back to INTERNAL_SERVER_ERROR ' , async ( ) => {
217+ it ( 'on error encoding failure, throws ' , async ( ) => {
218218 matcher . match . mockResolvedValue ( {
219219 path : [ 'ping' ] ,
220220 procedure : ping ,
@@ -231,22 +231,14 @@ describe('standardHandler', () => {
231231 codec . encodeError . mockImplementationOnce ( ( ) => {
232232 throw encodeError
233233 } )
234- codec . encodeError . mockReturnValueOnce ( response )
235234
236- const result = await handler . handle ( request , {
235+ await expect ( handler . handle ( request , {
237236 context : { db : 'postgres' } ,
238237 prefix : '/api/v1' ,
239- } )
238+ } ) ) . rejects . toBe ( encodeError )
240239
241- expect ( result ) . toEqual ( { matched : true , response } )
242-
243- expect ( codec . encodeError ) . toHaveBeenCalledTimes ( 2 )
244- expect ( codec . encodeError ) . toHaveBeenNthCalledWith ( 1 , error )
245- expect ( codec . encodeError ) . toHaveBeenNthCalledWith ( 2 , expect . objectContaining ( {
246- code : 'INTERNAL_SERVER_ERROR' ,
247- data : undefined ,
248- cause : encodeError ,
249- } ) )
240+ expect ( codec . encodeError ) . toHaveBeenCalledTimes ( 1 )
241+ expect ( codec . encodeError ) . toHaveBeenCalledWith ( error )
250242 } )
251243
252244 it ( 'on decode error, converts to BAD_REQUEST before interceptors see it' , async ( ) => {
0 commit comments