File tree Expand file tree Collapse file tree 2 files changed +22
-30
lines changed
packages/fetch-http-handler/src Expand file tree Collapse file tree 2 files changed +22
-30
lines changed Original file line number Diff line number Diff line change @@ -6,12 +6,31 @@ import { createRequest } from "./create-request";
6
6
import { FetchHttpHandler , keepAliveSupport } from "./fetch-http-handler" ;
7
7
8
8
vi . mock ( "./create-request" , async ( ) => {
9
- const actual : any = await vi . importActual ( "./create-request" ) ;
10
9
return {
11
- createRequest : vi . fn ( ) . mockImplementation ( actual . createRequest ) ,
10
+ createRequest : vi . fn ( ) . mockImplementation ( ( _url , options ) => {
11
+ const url = new URL ( _url ) ;
12
+ return {
13
+ protocol : url . protocol ,
14
+ hostname : url . hostname ,
15
+ ...options ,
16
+ } as any ;
17
+ } ) ,
12
18
} ;
13
19
} ) ;
14
20
21
+ vi . spyOn ( global , "fetch" ) . mockImplementation ( ( async ( ) => {
22
+ return {
23
+ headers : {
24
+ entries ( ) {
25
+ return [ ] ;
26
+ } ,
27
+ } ,
28
+ async blob ( ) {
29
+ return undefined ;
30
+ } ,
31
+ } ;
32
+ } ) as any ) ;
33
+
15
34
( typeof Blob === "function" ? describe : describe . skip ) ( FetchHttpHandler . name , ( ) => {
16
35
interface MockHttpRequestOptions {
17
36
method ?: string ;
@@ -23,7 +42,7 @@ vi.mock("./create-request", async () => {
23
42
}
24
43
25
44
const getMockHttpRequest = ( options : MockHttpRequestOptions ) : HttpRequest =>
26
- new HttpRequest ( { hostname : "example.com " , ...options } ) ;
45
+ new HttpRequest ( { hostname : "localhost" , protocol : "http ", ...options } ) ;
27
46
28
47
describe ( "fetch" , ( ) => {
29
48
beforeAll ( ( ) => {
Original file line number Diff line number Diff line change @@ -2287,7 +2287,6 @@ __metadata:
2287
2287
" @types/node " : ^16.18.96
2288
2288
concurrently : 7.0.0
2289
2289
downlevel-dts : 0.10.1
2290
- nock : ^13.0.2
2291
2290
rimraf : 3.0.2
2292
2291
tslib : ^2.6.2
2293
2292
typedoc : 0.23.23
@@ -7582,13 +7581,6 @@ __metadata:
7582
7581
languageName : node
7583
7582
linkType : hard
7584
7583
7585
- " json-stringify-safe@npm:^5.0.1 " :
7586
- version : 5.0.1
7587
- resolution : " json-stringify-safe@npm:5.0.1"
7588
- checksum : 48ec0adad5280b8a96bb93f4563aa1667fd7a36334f79149abd42446d0989f2ddc58274b479f4819f1f00617957e6344c886c55d05a4e15ebb4ab931e4a6a8ee
7589
- languageName : node
7590
- linkType : hard
7591
-
7592
7584
" json5@npm:^2.2.2, json5@npm:^2.2.3 " :
7593
7585
version : 2.2.3
7594
7586
resolution : " json5@npm:2.2.3"
@@ -8174,18 +8166,6 @@ __metadata:
8174
8166
languageName : node
8175
8167
linkType : hard
8176
8168
8177
- " nock@npm:^13.0.2 " :
8178
- version : 13.3.1
8179
- resolution : " nock@npm:13.3.1"
8180
- dependencies :
8181
- debug : ^4.1.0
8182
- json-stringify-safe : ^5.0.1
8183
- lodash : ^4.17.21
8184
- propagate : ^2.0.0
8185
- checksum : 0f2a73e8432f6b5650656c53eef99f9e5bbde3df538dc2f07057edc4438cfc61a394c9d06dd82e60f6e86d42433f20f3c04364a1f088beee7bf03a24e3f0fdd0
8186
- languageName : node
8187
- linkType : hard
8188
-
8189
8169
" node-fetch@npm:2.6.7 " :
8190
8170
version : 2.6.7
8191
8171
resolution : " node-fetch@npm:2.6.7"
@@ -8756,13 +8736,6 @@ __metadata:
8756
8736
languageName : node
8757
8737
linkType : hard
8758
8738
8759
- " propagate@npm:^2.0.0 " :
8760
- version : 2.0.1
8761
- resolution : " propagate@npm:2.0.1"
8762
- checksum : c4febaee2be0979e82fb6b3727878fd122a98d64a7fa3c9d09b0576751b88514a9e9275b1b92e76b364d488f508e223bd7e1dcdc616be4cdda876072fbc2a96c
8763
- languageName : node
8764
- linkType : hard
8765
-
8766
8739
" proxy-from-env@npm:1.1.0 " :
8767
8740
version : 1.1.0
8768
8741
resolution : " proxy-from-env@npm:1.1.0"
You can’t perform that action at this time.
0 commit comments