Skip to content

Commit efedb98

Browse files
chore(deps): update dependency fetch-mock to v12 (#581)
* chore(deps): update dependency fetch-mock to v12 * test: update for fetch-mock v12 --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: wolfy1339 <[email protected]>
1 parent 263247c commit efedb98

8 files changed

+48
-41
lines changed

package-lock.json

Lines changed: 23 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"@vitest/coverage-v8": "^3.0.0",
3535
"esbuild": "^0.24.0",
3636
"express": "^4.17.1",
37-
"fetch-mock": "^11.1.1",
37+
"fetch-mock": "^12.0.0",
3838
"glob": "^10.0.0",
3939
"mockdate": "^3.0.2",
4040
"prettier": "3.4.2",

test/each-installation.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe("app.eachInstallation", () => {
4646

4747
beforeEach(() => {
4848
MockDate.set(0);
49-
mock = fetchMock.sandbox();
49+
mock = fetchMock.createInstance();
5050

5151
app = new App({
5252
appId: APP_ID,
@@ -60,7 +60,7 @@ describe("app.eachInstallation", () => {
6060
},
6161
Octokit: Octokit.defaults({
6262
request: {
63-
fetch: mock,
63+
fetch: mock.fetchHandler,
6464
},
6565
}),
6666
});

test/each-repository.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe("app.eachRepository", () => {
4646

4747
beforeEach(() => {
4848
MockDate.set(0);
49-
mock = fetchMock.sandbox();
49+
mock = fetchMock.createInstance();
5050

5151
app = new App({
5252
appId: APP_ID,
@@ -60,7 +60,7 @@ describe("app.eachRepository", () => {
6060
},
6161
Octokit: Octokit.defaults({
6262
request: {
63-
fetch: mock,
63+
fetch: mock.fetchHandler,
6464
},
6565
}),
6666
});
@@ -187,7 +187,7 @@ describe("app.eachRepository.iterator", () => {
187187

188188
beforeEach(() => {
189189
MockDate.set(0);
190-
mock = fetchMock.sandbox();
190+
mock = fetchMock.createInstance();
191191

192192
app = new App({
193193
appId: APP_ID,
@@ -201,7 +201,7 @@ describe("app.eachRepository.iterator", () => {
201201
},
202202
Octokit: Octokit.defaults({
203203
request: {
204-
fetch: mock,
204+
fetch: mock.fetchHandler,
205205
},
206206
}),
207207
});
@@ -268,6 +268,6 @@ describe("app.eachRepository.iterator", () => {
268268
expect(repository.full_name).toEqual("octokit/octokit.js");
269269
}
270270

271-
expect(mock.done()).toBe(true);
271+
expect(mock.callHistory.done()).toBe(true);
272272
});
273273
});

test/get-installation-octokit.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe("app.getInstallationOctokit", () => {
4646

4747
beforeEach(() => {
4848
MockDate.set(0);
49-
mock = fetchMock.sandbox();
49+
mock = fetchMock.createInstance();
5050

5151
app = new App({
5252
appId: APP_ID,
@@ -60,7 +60,7 @@ describe("app.getInstallationOctokit", () => {
6060
},
6161
Octokit: Octokit.defaults({
6262
request: {
63-
fetch: mock,
63+
fetch: mock.fetchHandler,
6464
},
6565
}),
6666
});

test/get-installation-url.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe("app.getInstallationUrl", () => {
4343

4444
beforeEach(() => {
4545
MockDate.set(0);
46-
mock = fetchMock.sandbox();
46+
mock = fetchMock.createInstance();
4747

4848
app = new App({
4949
appId: APP_ID,
@@ -57,7 +57,7 @@ describe("app.getInstallationUrl", () => {
5757
},
5858
Octokit: Octokit.defaults({
5959
request: {
60-
fetch: mock,
60+
fetch: mock.fetchHandler,
6161
},
6262
}),
6363
});
@@ -73,7 +73,7 @@ describe("app.getInstallationUrl", () => {
7373
"[@octokit/app] unable to fetch metadata for app",
7474
);
7575

76-
expect(mock.done()).toBe(true);
76+
expect(mock.callHistory.done()).toBe(true);
7777
});
7878

7979
test("returns correct url", async () => {
@@ -84,7 +84,7 @@ describe("app.getInstallationUrl", () => {
8484
const url = await app.getInstallationUrl();
8585

8686
expect(url).toEqual("https://github.com/apps/octokit/installations/new");
87-
expect(mock.done()).toBe(true);
87+
expect(mock.callHistory.done()).toBe(true);
8888
});
8989

9090
test("caches url", async () => {
@@ -101,7 +101,7 @@ describe("app.getInstallationUrl", () => {
101101
expect(urls).toEqual(
102102
new Array(3).fill("https://github.com/apps/octokit/installations/new"),
103103
);
104-
expect(mock.done()).toBe(true);
104+
expect(mock.callHistory.done()).toBe(true);
105105
});
106106

107107
test("does not cache state", async () => {
@@ -119,7 +119,7 @@ describe("app.getInstallationUrl", () => {
119119
expect(urlWithState).toEqual(
120120
`https://github.com/apps/octokit/installations/new?state=${state}`,
121121
);
122-
expect(mock.done()).toBe(true);
122+
expect(mock.callHistory.done()).toBe(true);
123123
});
124124

125125
test("adds the url-encoded state string to the url", async () => {
@@ -133,7 +133,7 @@ describe("app.getInstallationUrl", () => {
133133
expect(url).toEqual(
134134
`https://github.com/apps/octokit/installations/new?state=${encodeURIComponent(state)}`,
135135
);
136-
expect(mock.done()).toBe(true);
136+
expect(mock.callHistory.done()).toBe(true);
137137
});
138138

139139
test("appends /permissions to the url when target_id present", async () => {
@@ -147,7 +147,7 @@ describe("app.getInstallationUrl", () => {
147147
expect(url).toEqual(
148148
`https://github.com/apps/octokit/installations/new/permissions?target_id=${target_id}`,
149149
);
150-
expect(mock.done()).toBe(true);
150+
expect(mock.callHistory.done()).toBe(true);
151151
});
152152

153153
test("adds both state and target_id to the url", async () => {
@@ -162,6 +162,6 @@ describe("app.getInstallationUrl", () => {
162162
expect(url).toEqual(
163163
`https://github.com/apps/octokit/installations/new/permissions?target_id=${target_id}&state=${state}`,
164164
);
165-
expect(mock.done()).toBe(true);
165+
expect(mock.callHistory.done()).toBe(true);
166166
});
167167
});

test/octokit.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ describe("app.octokit", () => {
5757

5858
beforeEach(() => {
5959
MockDate.set(0);
60-
mock = fetchMock.sandbox();
60+
mock = fetchMock.createInstance();
6161

6262
app = new App(
6363
Object.assign(
6464
{
6565
Octokit: Octokit.defaults({
6666
request: {
67-
fetch: mock,
67+
fetch: mock.fetchHandler,
6868
},
6969
}),
7070
},

test/readme-examples.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe("README examples", () => {
4949

5050
beforeEach(() => {
5151
MockDate.set(0);
52-
mock = fetchMock.sandbox();
52+
mock = fetchMock.createInstance();
5353

5454
app = new App({
5555
appId: APP_ID,
@@ -63,7 +63,7 @@ describe("README examples", () => {
6363
},
6464
Octokit: Octokit.defaults({
6565
request: {
66-
fetch: mock,
66+
fetch: mock.fetchHandler,
6767
},
6868
}),
6969
log: console,
@@ -249,7 +249,7 @@ describe("README examples", () => {
249249

250250
server.close();
251251

252-
expect(mock.done()).toBe(true);
252+
expect(mock.callHistory.done()).toBe(true);
253253
});
254254

255255
test('app.oauth.on("token", handler)', async () => {
@@ -300,6 +300,6 @@ describe("README examples", () => {
300300

301301
server.close();
302302

303-
expect(mock.done()).toBe(true);
303+
expect(mock.callHistory.done()).toBe(true);
304304
});
305305
});

0 commit comments

Comments
 (0)