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>({
78
78
new Proxy < T > ( { } as T , {
79
79
// eslint-disable-next-line sonarjs/cognitive-complexity
80
80
get ( _ , prop ) {
81
- if ( prop === 'then' ) return ;
82
81
const method = prop as keyof T ;
83
82
const urlPath = paths [ method ] ;
84
- if ( ! urlPath )
85
- throw new ProviderError ( ProviderFailure . NotImplemented , `HttpProvider missing path for '${ prop . toString ( ) } '` ) ;
83
+ if ( ! urlPath ) return ;
86
84
return async ( ...args : any [ ] ) => {
87
85
try {
88
86
const req : AxiosRequestConfig = {
@@ -123,5 +121,9 @@ export const createHttpProvider = <T extends Provider>({
123
121
throw new ProviderError ( ProviderFailure . Unknown , error ) ;
124
122
}
125
123
} ;
124
+ } ,
125
+
126
+ has ( _ , prop ) {
127
+ return prop in paths ;
126
128
}
127
129
} ) ;
Original file line number Diff line number Diff line change @@ -63,10 +63,16 @@ describe('createHttpProvider', () => {
63
63
if ( closeServer ) await closeServer ( ) ;
64
64
} ) ;
65
65
66
- it ( 'attempting to access unimplemented method throws ProviderError ' , async ( ) => {
66
+ it ( 'attempting to access unimplemented method returns undefined ' , async ( ) => {
67
67
const provider = createTxSubmitProviderClient ( ) ;
68
+ expect ( 'doesNotExist' in provider ) . toBe ( false ) ;
68
69
// 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 ) ;
70
76
} ) ;
71
77
72
78
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