Skip to content

Commit 79995f4

Browse files
committed
chore(deps): upgrade fetch-mock to v12
1 parent 51c1473 commit 79995f4

File tree

9 files changed

+1514
-2130
lines changed

9 files changed

+1514
-2130
lines changed

package-lock.json

Lines changed: 42 additions & 602 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
@@ -45,7 +45,7 @@
4545
"c8": "10.1.3",
4646
"cpy": "12.1.0",
4747
"cz-conventional-changelog": "3.3.0",
48-
"fetch-mock": "npm:@gr2m/[email protected]",
48+
"fetch-mock": "12.6.0",
4949
"lockfile-lint": "4.14.1",
5050
"ls-engines": "0.9.3",
5151
"npm-run-all2": "8.0.4",

test/add-channel.test.js

Lines changed: 62 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@ test("Update a release", async (t) => {
3434
const releaseUrl = `https://github.com/${owner}/${repo}/releases/${nextRelease.version}`;
3535
const releaseId = 1;
3636

37-
const fetch = fetchMock
38-
.sandbox()
39-
.getOnce(
37+
const fm = fetchMock
38+
.createInstance()
39+
.get(
4040
`https://api.github.local/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`,
4141
{
4242
id: releaseId,
4343
},
44+
{ repeat: 1 },
4445
)
45-
.patchOnce(
46+
.patch(
4647
`https://api.github.local/repos/${owner}/${repo}/releases/${releaseId}`,
4748
{
4849
html_url: releaseUrl,
@@ -53,6 +54,7 @@ test("Update a release", async (t) => {
5354
name: nextRelease.name,
5455
prerelease: false,
5556
},
57+
repeat: 1,
5658
},
5759
);
5860

@@ -68,7 +70,7 @@ test("Update a release", async (t) => {
6870
{
6971
Octokit: TestOctokit.defaults((options) => ({
7072
...options,
71-
request: { ...options.request, fetch },
73+
request: { ...options.request, fetch: fm.fetchHandler },
7274
})),
7375
},
7476
);
@@ -78,7 +80,7 @@ test("Update a release", async (t) => {
7880
"Updated GitHub release: %s",
7981
releaseUrl,
8082
]);
81-
t.true(fetch.done());
83+
t.true(fm.callHistory.done());
8284
});
8385

8486
test("Update a maintenance release", async (t) => {
@@ -96,15 +98,16 @@ test("Update a maintenance release", async (t) => {
9698
const releaseUrl = `https://github.com/${owner}/${repo}/releases/${nextRelease.version}`;
9799
const releaseId = 1;
98100

99-
const fetch = fetchMock
100-
.sandbox()
101-
.getOnce(
101+
const fm = fetchMock
102+
.createInstance()
103+
.get(
102104
`https://api.github.local/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`,
103105
{
104106
id: releaseId,
105107
},
108+
{ repeat: 1 },
106109
)
107-
.patchOnce(
110+
.patch(
108111
`https://api.github.local/repos/${owner}/${repo}/releases/${releaseId}`,
109112
{
110113
html_url: releaseUrl,
@@ -115,6 +118,7 @@ test("Update a maintenance release", async (t) => {
115118
name: nextRelease.name,
116119
prerelease: false,
117120
},
121+
repeat: 1,
118122
},
119123
);
120124

@@ -130,7 +134,7 @@ test("Update a maintenance release", async (t) => {
130134
{
131135
Octokit: TestOctokit.defaults((options) => ({
132136
...options,
133-
request: { ...options.request, fetch },
137+
request: { ...options.request, fetch: fm.fetchHandler },
134138
})),
135139
},
136140
);
@@ -140,7 +144,7 @@ test("Update a maintenance release", async (t) => {
140144
"Updated GitHub release: %s",
141145
releaseUrl,
142146
]);
143-
t.true(fetch.done());
147+
t.true(fm.callHistory.done());
144148
});
145149

146150
test("Update a prerelease", async (t) => {
@@ -157,15 +161,16 @@ test("Update a prerelease", async (t) => {
157161
const releaseUrl = `https://github.com/${owner}/${repo}/releases/${nextRelease.version}`;
158162
const releaseId = 1;
159163

160-
const fetch = fetchMock
161-
.sandbox()
162-
.getOnce(
164+
const fm = fetchMock
165+
.createInstance()
166+
.get(
163167
`https://api.github.local/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`,
164168
{
165169
id: releaseId,
166170
},
171+
{ repeat: 1 },
167172
)
168-
.patchOnce(
173+
.patch(
169174
`https://api.github.local/repos/${owner}/${repo}/releases/${releaseId}`,
170175
{
171176
html_url: releaseUrl,
@@ -176,6 +181,7 @@ test("Update a prerelease", async (t) => {
176181
name: nextRelease.name,
177182
prerelease: false,
178183
},
184+
repeat: 1,
179185
},
180186
);
181187

@@ -191,7 +197,7 @@ test("Update a prerelease", async (t) => {
191197
{
192198
Octokit: TestOctokit.defaults((options) => ({
193199
...options,
194-
request: { ...options.request, fetch },
200+
request: { ...options.request, fetch: fm.fetchHandler },
195201
})),
196202
},
197203
);
@@ -201,7 +207,7 @@ test("Update a prerelease", async (t) => {
201207
"Updated GitHub release: %s",
202208
releaseUrl,
203209
]);
204-
t.true(fetch.done());
210+
t.true(fm.callHistory.done());
205211
});
206212

207213
test("Update a release with a custom github url", async (t) => {
@@ -222,15 +228,16 @@ test("Update a release with a custom github url", async (t) => {
222228
const releaseUrl = `${env.GH_URL}/${owner}/${repo}/releases/${nextRelease.version}`;
223229
const releaseId = 1;
224230

225-
const fetch = fetchMock
226-
.sandbox()
227-
.getOnce(
231+
const fm = fetchMock
232+
.createInstance()
233+
.get(
228234
`https://othertesturl.com:443/prefix/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`,
229235
{
230236
id: releaseId,
231237
},
238+
{ repeat: 1 },
232239
)
233-
.patchOnce(
240+
.patch(
234241
`https://othertesturl.com:443/prefix/repos/${owner}/${repo}/releases/${releaseId}`,
235242
{
236243
html_url: releaseUrl,
@@ -241,6 +248,7 @@ test("Update a release with a custom github url", async (t) => {
241248
name: nextRelease.name,
242249
prerelease: false,
243250
},
251+
repeat: 1,
244252
},
245253
);
246254

@@ -256,7 +264,7 @@ test("Update a release with a custom github url", async (t) => {
256264
{
257265
Octokit: TestOctokit.defaults((options) => ({
258266
...options,
259-
request: { ...options.request, fetch },
267+
request: { ...options.request, fetch: fm.fetchHandler },
260268
})),
261269
},
262270
);
@@ -266,7 +274,7 @@ test("Update a release with a custom github url", async (t) => {
266274
"Updated GitHub release: %s",
267275
releaseUrl,
268276
]);
269-
t.true(fetch.done());
277+
t.true(fm.callHistory.done());
270278
});
271279

272280
test("Create the new release if current one is missing", async (t) => {
@@ -282,13 +290,14 @@ test("Create the new release if current one is missing", async (t) => {
282290
const options = { repositoryUrl: `https://github.com/${owner}/${repo}.git` };
283291
const releaseUrl = `https://github.com/${owner}/${repo}/releases/${nextRelease.version}`;
284292

285-
const fetch = fetchMock
286-
.sandbox()
287-
.getOnce(
293+
const fm = fetchMock
294+
.createInstance()
295+
.get(
288296
`https://api.github.local/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`,
289297
404,
298+
{ repeat: 1 },
290299
)
291-
.postOnce(
300+
.post(
292301
`https://api.github.local/repos/${owner}/${repo}/releases`,
293302
{
294303
html_url: releaseUrl,
@@ -300,6 +309,7 @@ test("Create the new release if current one is missing", async (t) => {
300309
body: nextRelease.notes,
301310
prerelease: false,
302311
},
312+
repeat: 1,
303313
},
304314
);
305315

@@ -315,7 +325,7 @@ test("Create the new release if current one is missing", async (t) => {
315325
{
316326
Octokit: TestOctokit.defaults((options) => ({
317327
...options,
318-
request: { ...options.request, fetch },
328+
request: { ...options.request, fetch: fm.fetchHandler },
319329
})),
320330
},
321331
);
@@ -329,7 +339,7 @@ test("Create the new release if current one is missing", async (t) => {
329339
"Published GitHub release: %s",
330340
releaseUrl,
331341
]);
332-
t.true(fetch.done());
342+
t.true(fm.callHistory.done());
333343
});
334344

335345
test("Throw error if cannot read current release", async (t) => {
@@ -344,11 +354,12 @@ test("Throw error if cannot read current release", async (t) => {
344354
};
345355
const options = { repositoryUrl: `https://github.com/${owner}/${repo}.git` };
346356

347-
const fetch = fetchMock
348-
.sandbox()
349-
.getOnce(
357+
const fm = fetchMock
358+
.createInstance()
359+
.get(
350360
`https://api.github.local/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`,
351361
500,
362+
{ repeat: 1 },
352363
);
353364

354365
const error = await t.throwsAsync(
@@ -364,14 +375,14 @@ test("Throw error if cannot read current release", async (t) => {
364375
{
365376
Octokit: TestOctokit.defaults((options) => ({
366377
...options,
367-
request: { ...options.request, fetch },
378+
request: { ...options.request, fetch: fm.fetchHandler },
368379
})),
369380
},
370381
),
371382
);
372383

373384
t.is(error.status, 500);
374-
t.true(fetch.done());
385+
t.true(fm.callHistory.done());
375386
});
376387

377388
test("Throw error if cannot create missing current release", async (t) => {
@@ -388,19 +399,21 @@ test("Throw error if cannot create missing current release", async (t) => {
388399
repositoryUrl: `https://github.com/${owner}/${repo}.git`,
389400
};
390401

391-
const fetch = fetchMock
392-
.sandbox()
393-
.getOnce(
402+
const fm = fetchMock
403+
.createInstance()
404+
.get(
394405
`https://api.github.local/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`,
395406
404,
407+
{ repeat: 1 },
396408
)
397-
.postOnce(`https://api.github.local/repos/${owner}/${repo}/releases`, 500, {
409+
.post(`https://api.github.local/repos/${owner}/${repo}/releases`, 500, {
398410
body: {
399411
tag_name: nextRelease.gitTag,
400412
name: nextRelease.name,
401413
body: nextRelease.notes,
402414
prerelease: false,
403415
},
416+
repeat: 1,
404417
});
405418

406419
const error = await t.throwsAsync(
@@ -416,14 +429,14 @@ test("Throw error if cannot create missing current release", async (t) => {
416429
{
417430
Octokit: TestOctokit.defaults((options) => ({
418431
...options,
419-
request: { ...options.request, fetch },
432+
request: { ...options.request, fetch: fm.fetchHandler },
420433
})),
421434
},
422435
),
423436
);
424437

425438
t.is(error.status, 500);
426-
t.true(fetch.done());
439+
t.true(fm.callHistory.done());
427440
});
428441

429442
test("Throw error if cannot update release", async (t) => {
@@ -439,13 +452,14 @@ test("Throw error if cannot update release", async (t) => {
439452
const options = { repositoryUrl: `https://github.com/${owner}/${repo}.git` };
440453
const releaseId = 1;
441454

442-
const fetch = fetchMock
443-
.sandbox()
444-
.getOnce(
455+
const fm = fetchMock
456+
.createInstance()
457+
.get(
445458
`https://api.github.local/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`,
446459
{ id: releaseId },
460+
{ repeat: 1 },
447461
)
448-
.patchOnce(
462+
.patch(
449463
`https://api.github.local/repos/${owner}/${repo}/releases/${releaseId}`,
450464
404,
451465
{
@@ -454,6 +468,7 @@ test("Throw error if cannot update release", async (t) => {
454468
name: nextRelease.name,
455469
prerelease: false,
456470
},
471+
repeat: 1,
457472
},
458473
);
459474

@@ -470,12 +485,12 @@ test("Throw error if cannot update release", async (t) => {
470485
{
471486
Octokit: TestOctokit.defaults((options) => ({
472487
...options,
473-
request: { ...options.request, fetch },
488+
request: { ...options.request, fetch: fm.fetchHandler },
474489
})),
475490
},
476491
),
477492
);
478493

479494
t.is(error.status, 404);
480-
t.true(fetch.done());
495+
t.true(fm.callHistory.done());
481496
});

0 commit comments

Comments
 (0)