File tree Expand file tree Collapse file tree 2 files changed +24
-5
lines changed
Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -43,12 +43,12 @@ export class JSONRPCClient extends ClientProxy {
4343 jsonrpc : "2.0" ,
4444 id : ++ id
4545 } )
46- . then ( res => Promise . resolve ( { jsonrpc, result : res , id } ) )
46+ . then ( res => ( { jsonrpc, result : res , id } ) )
4747 . catch ( err => {
4848 const { code, message, data } = err . response . data ;
4949 let resp = { code, message, data } ;
5050
51- return Promise . resolve ( { jsonrpc, error : resp , id } ) ;
51+ return { jsonrpc, error : resp , id } ;
5252 } ) ;
5353 } ;
5454 }
Original file line number Diff line number Diff line change @@ -37,15 +37,34 @@ describe("json-rpc-e2e", () => {
3737 . then ( res => expect ( res . result . data ) . toStrictEqual ( { data : "hi" } ) ) ;
3838 } ) ;
3939
40- it ( `should return an error from JSONRPCClient call` , ( ) => {
40+ it ( `should check error object properties from JSONRPCClient call` , ( ) => {
41+ const jsonRpcErrorObj = {
42+ id : expect . stringMatching ,
43+ jsonrpc : "" ,
44+ error : {
45+ message : "" ,
46+ code : 403 ,
47+ data : {
48+ fromService : "" ,
49+ params : { data : "" }
50+ }
51+ }
52+ } ;
53+ return service . testError ( { data : "hi" } ) . then ( res => {
54+ expect ( res ) . toHaveProperty ( "id" ) ;
55+ expect ( res ) . toHaveProperty ( "jsonrpc" ) ;
56+ expect ( res ) . toHaveProperty ( "error" ) ;
57+ } ) ;
58+ } ) ;
59+
60+ it ( `should return an error and check error data from JSONRPCClient call` , ( ) => {
4161 const errorObj = {
4262 message : "RPC EXCEPTION" ,
4363 code : 403 ,
4464 data : {
4565 fromService : "Test Service" ,
4666 params : { data : "hi" }
47- } ,
48- id : 2
67+ }
4968 } ;
5069
5170 return service . testError ( { data : "hi" } ) . then ( res => expect ( res . error ) . toStrictEqual ( errorObj ) ) ;
You can’t perform that action at this time.
0 commit comments