From bea63273e370e7ed709a80cffb402c05a01065da Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 26 Dec 2024 13:39:30 -0500 Subject: [PATCH] chore(deps): update dependency fetch-mock to v12 (#640) * chore(deps): update dependency fetch-mock to v12 * updates tests to use the new v12 fetch-mock apis --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Nick Floyd --- package-lock.json | 62 ++++++++++++------- package.json | 2 +- test/compose-paginate.test.ts | 8 +-- test/issues.test.ts | 16 ++--- test/paginate.test.ts | 110 +++++++++++++++++----------------- 5 files changed, 108 insertions(+), 90 deletions(-) diff --git a/package-lock.json b/package-lock.json index 502d9758..00e0ee0d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "@types/node": "^22.0.0", "@vitest/coverage-v8": "^2.0.2", "esbuild": "^0.24.0", - "fetch-mock": "^11.0.0", + "fetch-mock": "^12.0.0", "github-openapi-graphql-query": "^4.0.0", "glob": "^11.0.0", "npm-run-all2": "^7.0.0", @@ -1055,6 +1055,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/glob-to-regexp": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/@types/glob-to-regexp/-/glob-to-regexp-0.4.4.tgz", + "integrity": "sha512-nDKoaKJYbnn1MZxUY0cA1bPmmgZbg0cTq7Rh13d0KWYNOiKbqoR+2d89SnRPszGh7ROzSwZ/GOjZ4jPbmmZ6Eg==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/http-cache-semantics": { "version": "4.0.1", "dev": true, @@ -1443,25 +1450,20 @@ } }, "node_modules/fetch-mock": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/fetch-mock/-/fetch-mock-11.0.0.tgz", - "integrity": "sha512-AD2Gh1xDQBLBs4iJpSxar19cTOH/Gu9hf1ko2J4hHW1UbR+ZHOfmIAqfT+Wlku4U8cYbffjaTbGv7mqe5kPi3w==", + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/fetch-mock/-/fetch-mock-12.0.0.tgz", + "integrity": "sha512-JSsjzoRN4rYqHa2/+8ushJGDsK9HGNTdBZo6Hrpu3KFN7Y03nRCt2VJ2WG4OUvyTUukOQ4TQIfjcFcEkMPGZ0Q==", "dev": true, "license": "MIT", "dependencies": { - "debug": "^4.1.1", + "@types/glob-to-regexp": "^0.4.4", "dequal": "^2.0.3", - "globrex": "^0.1.2", - "is-subset": "^0.1.1", + "glob-to-regexp": "^0.4.1", + "is-subset-of": "^3.1.10", "regexparam": "^3.0.0" }, "engines": { - "node": ">=8.0.0" - }, - "peerDependenciesMeta": { - "node-fetch": { - "optional": true - } + "node": ">=18.11.0" } }, "node_modules/foreground-child": { @@ -1584,6 +1586,13 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/glob-to-regexp": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", + "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==", + "dev": true, + "license": "BSD-2-Clause" + }, "node_modules/glob/node_modules/minimatch": { "version": "10.0.1", "dev": true, @@ -1598,13 +1607,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/globrex": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz", - "integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==", - "dev": true, - "license": "MIT" - }, "node_modules/got": { "version": "11.8.6", "dev": true, @@ -1681,10 +1683,16 @@ "node": ">=8" } }, - "node_modules/is-subset": { - "version": "0.1.1", + "node_modules/is-subset-of": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/is-subset-of/-/is-subset-of-3.1.10.tgz", + "integrity": "sha512-avvaYgVmYWyaZ1NDFiv4y9JGkrE2je3op1Po4VYKKJKR8H2qVPsg1GZuuXl5elCTxTlwAIsrAjWAs4BVrISFRw==", + "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.", "dev": true, - "license": "MIT" + "license": "MIT", + "dependencies": { + "typedescriptor": "3.0.2" + } }, "node_modules/isexe": { "version": "2.0.0", @@ -2579,6 +2587,14 @@ "dev": true, "license": "0BSD" }, + "node_modules/typedescriptor": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/typedescriptor/-/typedescriptor-3.0.2.tgz", + "integrity": "sha512-hyVbaCUd18UiXk656g/imaBLMogpdijIEpnhWYrSda9rhvO4gOU16n2nh7xG5lv/rjumnZzGOdz0CEGTmFe0fQ==", + "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.", + "dev": true, + "license": "MIT" + }, "node_modules/typescript": { "version": "5.3.3", "dev": true, diff --git a/package.json b/package.json index 8f8b21d4..4c2f8f2b 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@types/node": "^22.0.0", "@vitest/coverage-v8": "^2.0.2", "esbuild": "^0.24.0", - "fetch-mock": "^11.0.0", + "fetch-mock": "^12.0.0", "github-openapi-graphql-query": "^4.0.0", "glob": "^11.0.0", "npm-run-all2": "^7.0.0", diff --git a/test/compose-paginate.test.ts b/test/compose-paginate.test.ts index 54b2293e..e6729df7 100644 --- a/test/compose-paginate.test.ts +++ b/test/compose-paginate.test.ts @@ -9,7 +9,7 @@ const ORG2 = { id: 2 }; test("composePaginateRest(octokit, route)", async () => { const mock = fetchMock - .sandbox() + .createInstance() .get("https://api.github.com/orgs/octokit/repos?per_page=1", { body: [ORG1], headers: { @@ -24,7 +24,7 @@ test("composePaginateRest(octokit, route)", async () => { const octokit = new Octokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -41,7 +41,7 @@ test("composePaginateRest(octokit, route)", async () => { test("composePaginateRest.iterator(octokit, route)", () => { const mock = fetchMock - .sandbox() + .createInstance() .getOnce("https://api.github.com/organizations", { body: [ORG1], headers: { @@ -56,7 +56,7 @@ test("composePaginateRest.iterator(octokit, route)", () => { const octokit = new Octokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); diff --git a/test/issues.test.ts b/test/issues.test.ts index f17ed68e..bb272315 100644 --- a/test/issues.test.ts +++ b/test/issues.test.ts @@ -8,7 +8,7 @@ import { paginateRest } from "../src/index.ts"; describe("https://github.com/octokit/plugin-paginate-rest.js/issues/46", () => { it("octokit.paginate('GET /projects/columns/{column}/cards', { column })", async () => { const mock = fetchMock - .sandbox() + .createInstance() .get("https://api.github.com/projects/columns/123/cards", { body: [{ id: 123 }], }); @@ -16,7 +16,7 @@ describe("https://github.com/octokit/plugin-paginate-rest.js/issues/46", () => { const TestOctokit = Octokit.plugin(paginateRest); const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -32,7 +32,7 @@ describe("https://github.com/octokit/plugin-paginate-rest.js/issues/46", () => { it("octokit.paginate(octokit.projects.listCards, { column })", async () => { const mock = fetchMock - .sandbox() + .createInstance() .get("https://api.github.com/projects/columns/123/cards", { body: [{ id: 123 }], }); @@ -40,7 +40,7 @@ describe("https://github.com/octokit/plugin-paginate-rest.js/issues/46", () => { const TestOctokit = Octokit.plugin(paginateRest, restEndpointMethods); const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -55,7 +55,7 @@ describe("https://github.com/octokit/plugin-paginate-rest.js/issues/46", () => { describe("https://github.com/octokit/plugin-paginate-rest.js/issues/158", () => { test("handle 204 response for `GET /repos/{owner}/{repo}/contributors` if repository is empty", async () => { const mock = fetchMock - .sandbox() + .createInstance() .get("https://api.github.com/repos/owner/empty-repo/contributors", { status: 204, }); @@ -63,7 +63,7 @@ describe("https://github.com/octokit/plugin-paginate-rest.js/issues/158", () => const TestOctokit = Octokit.plugin(paginateRest); const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -80,7 +80,7 @@ describe("https://github.com/octokit/plugin-paginate-rest.js/issues/158", () => test("handle 409 response for `GET /repos/{owner}/{repo}/commits` if repository is empty", async () => { const mock = fetchMock - .sandbox() + .createInstance() .get("https://api.github.com/repos/owner/empty-repo/commits", { status: 409, body: { @@ -93,7 +93,7 @@ describe("https://github.com/octokit/plugin-paginate-rest.js/issues/158", () => const TestOctokit = Octokit.plugin(paginateRest); const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); diff --git a/test/paginate.test.ts b/test/paginate.test.ts index ece4fec8..08028448 100644 --- a/test/paginate.test.ts +++ b/test/paginate.test.ts @@ -12,7 +12,7 @@ const TestOctokit = Octokit.plugin(paginateRest, restEndpointMethods); describe("pagination", () => { it(".paginate()", async () => { const mock = fetchMock - .sandbox() + .createInstance() .get("https://api.github.com/orgs/octokit/repos?per_page=1", { body: [ORG1], headers: { @@ -27,7 +27,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -63,7 +63,7 @@ describe("pagination", () => { it(".paginate(request)", async () => { const mock = fetchMock - .sandbox() + .createInstance() .getOnce("https://api.github.com/organizations", { body: [ORG1], headers: { @@ -78,7 +78,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -88,7 +88,7 @@ describe("pagination", () => { it(".paginate(request, options)", async () => { const mock = fetchMock - .sandbox() + .createInstance() .getOnce("https://api.github.com/orgs/octokit/repos?per_page=1", { body: [ORG1], headers: { @@ -106,7 +106,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -122,7 +122,7 @@ describe("pagination", () => { it(".paginate(request, options, mapFunction)", async () => { const mock = fetchMock - .sandbox() + .createInstance() .getOnce("https://api.github.com/orgs/octokit/repos?per_page=1", { body: [ORG1], headers: { @@ -140,7 +140,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -157,7 +157,7 @@ describe("pagination", () => { it(".paginate() with map function returning undefined", () => { const mock = fetchMock - .sandbox() + .createInstance() .get("https://api.github.com/orgs/octokit/repos?per_page=1", { body: [ORG1], headers: { @@ -172,7 +172,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -189,7 +189,7 @@ describe("pagination", () => { it(".paginate() with early exit", () => { const mock = fetchMock - .sandbox() + .createInstance() .get("https://api.github.com/orgs/octokit/repos?per_page=1", { body: [ORG1], headers: { @@ -204,7 +204,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -224,7 +224,7 @@ describe("pagination", () => { it(".paginate() with Link header pointing to different path", () => { const mock = fetchMock - .sandbox() + .createInstance() .get("https://api.github.com/orgs/octokit/repos?per_page=1", { body: [{ id: 1 }], headers: { @@ -239,7 +239,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -252,7 +252,7 @@ describe("pagination", () => { it("autopagination", () => { const mock = fetchMock - .sandbox() + .createInstance() .get("https://api.github.com/orgs/octokit/repos?per_page=1", { body: [{ id: 1 }], headers: { @@ -267,7 +267,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -294,13 +294,15 @@ describe("pagination", () => { }); it(".paginate.iterator for endpoints that don’t paginate", () => { - const mock = fetchMock.sandbox().get("https://api.github.com/orgs/myorg", { - body: ORG1, - }); + const mock = fetchMock + .createInstance() + .get("https://api.github.com/orgs/myorg", { + body: ORG1, + }); const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -319,7 +321,7 @@ describe("pagination", () => { it("paginate.iterator(route)", () => { const mock = fetchMock - .sandbox() + .createInstance() .getOnce("https://api.github.com/organizations", { body: [ORG1], headers: { @@ -334,7 +336,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -356,7 +358,7 @@ describe("pagination", () => { it("paginate.iterator(route, parameters)", () => { const mock = fetchMock - .sandbox() + .createInstance() .get("https://api.github.com/orgs/octokit/repos?per_page=1", { body: [ORG1], headers: { @@ -371,7 +373,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -396,7 +398,7 @@ describe("pagination", () => { it("paginate.iterator(options)", () => { const mock = fetchMock - .sandbox() + .createInstance() .getOnce("https://api.github.com/organizations", { body: [ORG1], headers: { @@ -411,7 +413,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -436,7 +438,7 @@ describe("pagination", () => { it("paginate.iterator(request)", () => { const mock = fetchMock - .sandbox() + .createInstance() .getOnce("https://api.github.com/organizations", { body: [ORG1], headers: { @@ -451,7 +453,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -495,7 +497,7 @@ describe("pagination", () => { "repo:web-platform-tests/wpt is:pr is:open updated:>2019-02-26", ); const mock = fetchMock - .sandbox() + .createInstance() .get(`https://api.github.com/search/issues?q=${query}&per_page=1`, { body: result1, headers: { @@ -516,7 +518,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -555,7 +557,7 @@ describe("pagination", () => { }; const mock = fetchMock - .sandbox() + .createInstance() .get(`https://api.github.com/installation/repositories?per_page=1`, { body: result1, headers: { @@ -576,7 +578,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -614,7 +616,7 @@ describe("pagination", () => { }; const mock = fetchMock - .sandbox() + .createInstance() .get(`https://api.github.com/user/installations?per_page=1`, { body: result1, headers: { @@ -632,7 +634,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -670,7 +672,7 @@ describe("pagination", () => { }; const mock = fetchMock - .sandbox() + .createInstance() .get( `https://api.github.com/repos/octocat/hello-world/actions/runs/123/artifacts?per_page=1`, { @@ -694,7 +696,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -732,7 +734,7 @@ describe("pagination", () => { }; const mock = fetchMock - .sandbox() + .createInstance() .get( `https://api.github.com/repos/octocat/hello-world/actions/secrets?per_page=1`, { @@ -756,7 +758,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -793,7 +795,7 @@ describe("pagination", () => { }; const mock = fetchMock - .sandbox() + .createInstance() .get( `https://api.github.com/repos/octocat/hello-world/actions/workflows?per_page=1`, { @@ -817,7 +819,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -853,7 +855,7 @@ describe("pagination", () => { }; const mock = fetchMock - .sandbox() + .createInstance() .get( `https://api.github.com/repos/octocat/hello-world/actions/runs/123/jobs?per_page=1`, { @@ -877,7 +879,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -914,7 +916,7 @@ describe("pagination", () => { }; const mock = fetchMock - .sandbox() + .createInstance() .get( `https://api.github.com/repos/octocat/hello-world/actions/workflows/123/runs?per_page=1`, { @@ -938,7 +940,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -978,7 +980,7 @@ describe("pagination", () => { }; const mock = fetchMock - .sandbox() + .createInstance() .get( `https://api.github.com/repos/octocat/hello-world/actions/runs?per_page=1`, { @@ -1002,7 +1004,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -1033,14 +1035,14 @@ describe("pagination", () => { }; const mock = fetchMock - .sandbox() + .createInstance() .get(`https://api.github.com/installation/repositories?per_page=1`, { body: result, }); const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -1066,7 +1068,7 @@ describe("pagination", () => { sha: "sha123", }; const mock = fetchMock - .sandbox() + .createInstance() .get( "https://api.github.com/repos/octokit/rest.js/commits/abc4567/status", { @@ -1076,7 +1078,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -1113,7 +1115,7 @@ describe("pagination", () => { }; const mock = fetchMock - .sandbox() + .createInstance() .get( `https://api.github.com/repos/octocat/hello-world/actions/runs?per_page=1`, { @@ -1137,7 +1139,7 @@ describe("pagination", () => { const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, }); @@ -1159,7 +1161,7 @@ describe("pagination", () => { it("404 error", async () => { const mock = fetchMock - .sandbox() + .createInstance() .get("https://api.github.com/repos/owner/non-existing-repo/issues", { status: 404, body: { @@ -1172,7 +1174,7 @@ describe("pagination", () => { const TestOctokit = Octokit.plugin(paginateRest); const octokit = new TestOctokit({ request: { - fetch: mock, + fetch: mock.fetchHandler, }, });