@@ -84,6 +84,14 @@ describe("router", () => {
8484 expect ( ( error as JSONRPCErrorObject ) . code ) . toBe ( - 32601 ) ;
8585 } ) ;
8686
87+ it ( "returns not found error when method is not implemented" , async ( ) => {
88+ const methodMapping = makeMethodMapping ( parsedExample . methods as MethodObject [ ] ) ;
89+ delete methodMapping [ "addition" ] ;
90+ const router = new Router ( parsedExample , methodMapping ) ;
91+ const { error } = await router . call ( "addition" , [ 2 , 2 ] ) ;
92+ expect ( ( error as JSONRPCErrorObject ) . code ) . toBe ( - 32601 ) ;
93+ } ) ;
94+
8795 it ( "returns param validation error when passing incorrect params" , async ( ) => {
8896 const router = new Router ( parsedExample , makeMethodMapping ( parsedExample . methods as MethodObject [ ] ) ) ;
8997 const { error } = await router . call ( "addition" , [ "123" , "321" ] ) ;
@@ -101,8 +109,9 @@ describe("router", () => {
101109 it ( "returns Unknown Error data when thrown" , async ( ) => {
102110 const router = new Router ( parsedExample , makeMethodMapping ( parsedExample . methods as MethodObject [ ] ) ) ;
103111 const { error } = await router . call ( "unknown-error" , [ ] ) ;
104- expect ( ( error as JSONRPCErrorObject ) . code ) . toBe ( 6969 ) ;
105- expect ( ( error as JSONRPCErrorObject ) . message ) . toBe ( "unknown error" ) ;
112+ expect ( ( error as JSONRPCErrorObject ) . code ) . toBe ( - 32603 ) ;
113+ expect ( ( error as JSONRPCErrorObject ) . message ) . toBe ( "Internal error" ) ;
114+ expect ( ( error as JSONRPCErrorObject ) . data ) . toBe ( "unanticpated crash" ) ;
106115 } ) ;
107116
108117 it ( "implements service discovery" , async ( ) => {
0 commit comments