File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
packages/cardano-services-client Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -78,11 +78,9 @@ export const createHttpProvider = <T extends Provider>({
7878 new Proxy < T > ( { } as T , {
7979 // eslint-disable-next-line sonarjs/cognitive-complexity
8080 get ( _ , prop ) {
81- if ( prop === 'then' ) return ;
8281 const method = prop as keyof T ;
8382 const urlPath = paths [ method ] ;
84- if ( ! urlPath )
85- throw new ProviderError ( ProviderFailure . NotImplemented , `HttpProvider missing path for '${ prop . toString ( ) } '` ) ;
83+ if ( ! urlPath ) return ;
8684 return async ( ...args : any [ ] ) => {
8785 try {
8886 const req : AxiosRequestConfig = {
@@ -123,5 +121,9 @@ export const createHttpProvider = <T extends Provider>({
123121 throw new ProviderError ( ProviderFailure . Unknown , error ) ;
124122 }
125123 } ;
124+ } ,
125+
126+ has ( _ , prop ) {
127+ return prop in paths ;
126128 }
127129 } ) ;
Original file line number Diff line number Diff line change @@ -63,10 +63,16 @@ describe('createHttpProvider', () => {
6363 if ( closeServer ) await closeServer ( ) ;
6464 } ) ;
6565
66- it ( 'attempting to access unimplemented method throws ProviderError ' , async ( ) => {
66+ it ( 'attempting to access unimplemented method returns undefined ' , async ( ) => {
6767 const provider = createTxSubmitProviderClient ( ) ;
68+ expect ( 'doesNotExist' in provider ) . toBe ( false ) ;
6869 // eslint-disable-next-line @typescript-eslint/no-explicit-any
69- expect ( ( ) => ( provider as any ) . doesNotExist ) . toThrowError ( ProviderError ) ;
70+ expect ( ( provider as any ) . doesNotExist ) . toBeUndefined ( ) ;
71+ } ) ;
72+
73+ it ( '"in" operator for implemented property returns true' , async ( ) => {
74+ const provider = createTxSubmitProviderClient ( ) ;
75+ expect ( 'healthCheck' in provider ) . toBe ( true ) ;
7076 } ) ;
7177
7278 it ( 'passes through axios options, merging custom header with the included provider version headers' , async ( ) => {
You can’t perform that action at this time.
0 commit comments