File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
packages/openapi-fetch/test/common Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -316,6 +316,26 @@ describe("request", () => {
316
316
await client . GET ( "/resources" ) ;
317
317
} ) ;
318
318
319
+ test ( "Can use custom Request class" , async ( ) => {
320
+ // sanity check to make sure the provided fetch function is actually called
321
+ expect . assertions ( 1 ) ;
322
+
323
+ class SpecialRequestImplementation extends Request { }
324
+
325
+ const customFetch = async ( input : Request ) => {
326
+ // make sure that the request is actually an instance of the custom request we provided
327
+ expect ( input ) . instanceOf ( SpecialRequestImplementation ) ;
328
+ return Promise . resolve ( Response . json ( { hello : "world" } ) ) ;
329
+ } ;
330
+
331
+ const client = createClient < paths > ( {
332
+ baseUrl : "https://fakeurl.example" ,
333
+ fetch : customFetch ,
334
+ } ) ;
335
+
336
+ await client . GET ( "/resources" , { Request : SpecialRequestImplementation } ) ;
337
+ } ) ;
338
+
319
339
test ( "can attach custom properties to request" , async ( ) => {
320
340
function createCustomFetch ( data : any ) {
321
341
const response = {
You can’t perform that action at this time.
0 commit comments