1- import fetchMock from "fetch-mock" ;
1+ import fetchMock , { FetchMock } from "fetch-mock" ;
22
33import { describe , it , expect } from "vitest" ;
44import { request } from "../src/index.ts" ;
@@ -9,19 +9,18 @@ describe("endpoint.defaults()", () => {
99 } ) ;
1010
1111 it ( "README example" , ( ) => {
12- const mock = fetchMock
13- . sandbox ( )
14- . mock (
15- "https://github-enterprise.acme-inc.com/api/v3/orgs/my-project/repos?per_page=100" ,
16- [ ] ,
17- {
18- headers : {
19- accept : "application/vnd.github.v3+json" ,
20- authorization : "token 0000000000000000000000000000000000000001" ,
21- "user-agent" : "myApp/1.2.3" ,
22- } ,
12+ const mock = fetchMock . createInstance ( ) ;
13+ mock . get (
14+ "https://github-enterprise.acme-inc.com/api/v3/orgs/my-project/repos?per_page=100" ,
15+ [ ] ,
16+ {
17+ headers : {
18+ accept : "application/vnd.github.v3+json" ,
19+ authorization : "token 0000000000000000000000000000000000000001" ,
20+ "user-agent" : "myApp/1.2.3" ,
2321 } ,
24- ) ;
22+ } ,
23+ ) ;
2524
2625 const myRequest = request . defaults ( {
2726 baseUrl : "https://github-enterprise.acme-inc.com/api/v3" ,
@@ -32,7 +31,7 @@ describe("endpoint.defaults()", () => {
3231 org : "my-project" ,
3332 per_page : 100 ,
3433 request : {
35- fetch : mock ,
34+ fetch : mock . fetchHandler ,
3635 } ,
3736 } ) ;
3837
@@ -42,19 +41,18 @@ describe("endpoint.defaults()", () => {
4241 } ) ;
4342
4443 it ( "repeated defaults" , ( ) => {
45- const mock = fetchMock
46- . sandbox ( )
47- . get (
48- "https://github-enterprise.acme-inc.com/api/v3/orgs/my-project/repos" ,
49- [ ] ,
50- {
51- headers : {
52- accept : "application/vnd.github.v3.raw+json" ,
53- authorization : "token 0000000000000000000000000000000000000001" ,
54- "user-agent" : "myApp/1.2.3" ,
55- } ,
44+ const mock = fetchMock . createInstance ( ) ;
45+ mock . get (
46+ "https://github-enterprise.acme-inc.com/api/v3/orgs/my-project/repos" ,
47+ [ ] ,
48+ {
49+ headers : {
50+ accept : "application/vnd.github.v3.raw+json" ,
51+ authorization : "token 0000000000000000000000000000000000000001" ,
52+ "user-agent" : "myApp/1.2.3" ,
5653 } ,
57- ) ;
54+ } ,
55+ ) ;
5856
5957 const myProjectRequest = request . defaults ( {
6058 baseUrl : "https://github-enterprise.acme-inc.com/api/v3" ,
@@ -66,7 +64,7 @@ describe("endpoint.defaults()", () => {
6664 } ,
6765 org : "my-project" ,
6866 request : {
69- fetch : mock ,
67+ fetch : mock . fetchHandler ,
7068 } ,
7169 } ) ;
7270 const myProjectRequestWithAuth = myProjectRequest . defaults ( {
0 commit comments