Skip to content

Commit

Permalink
chore(deps): update dependency fetch-mock to v12 (#723)
Browse files Browse the repository at this point in the history
* 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 <nicholas.floyd.info@gmail.com>
  • Loading branch information
renovate[bot] and nickfloyd authored Nov 9, 2024
1 parent 1ffa99b commit 2baa69b
Show file tree
Hide file tree
Showing 4 changed files with 305 additions and 275 deletions.
62 changes: 39 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@types/node": "^22.0.0",
"@vitest/coverage-v8": "^2.0.0",
"esbuild": "^0.24.0",
"fetch-mock": "^11.0.0",
"fetch-mock": "^12.0.0",
"glob": "^11.0.0",
"prettier": "3.3.3",
"semantic-release-plugin-update-version-in-files": "^1.0.0",
Expand Down
52 changes: 25 additions & 27 deletions test/defaults.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fetchMock from "fetch-mock";
import fetchMock, { FetchMock } from "fetch-mock";

import { describe, it, expect } from "vitest";
import { request } from "../src/index.ts";
Expand All @@ -9,19 +9,18 @@ describe("endpoint.defaults()", () => {
});

it("README example", () => {
const mock = fetchMock
.sandbox()
.mock(
"https://github-enterprise.acme-inc.com/api/v3/orgs/my-project/repos?per_page=100",
[],
{
headers: {
accept: "application/vnd.github.v3+json",
authorization: "token 0000000000000000000000000000000000000001",
"user-agent": "myApp/1.2.3",
},
const mock = fetchMock.createInstance();
mock.get(
"https://github-enterprise.acme-inc.com/api/v3/orgs/my-project/repos?per_page=100",
[],
{
headers: {
accept: "application/vnd.github.v3+json",
authorization: "token 0000000000000000000000000000000000000001",
"user-agent": "myApp/1.2.3",
},
);
},
);

const myRequest = request.defaults({
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
Expand All @@ -32,7 +31,7 @@ describe("endpoint.defaults()", () => {
org: "my-project",
per_page: 100,
request: {
fetch: mock,
fetch: mock.fetchHandler,
},
});

Expand All @@ -42,19 +41,18 @@ describe("endpoint.defaults()", () => {
});

it("repeated defaults", () => {
const mock = fetchMock
.sandbox()
.get(
"https://github-enterprise.acme-inc.com/api/v3/orgs/my-project/repos",
[],
{
headers: {
accept: "application/vnd.github.v3.raw+json",
authorization: "token 0000000000000000000000000000000000000001",
"user-agent": "myApp/1.2.3",
},
const mock = fetchMock.createInstance();
mock.get(
"https://github-enterprise.acme-inc.com/api/v3/orgs/my-project/repos",
[],
{
headers: {
accept: "application/vnd.github.v3.raw+json",
authorization: "token 0000000000000000000000000000000000000001",
"user-agent": "myApp/1.2.3",
},
);
},
);

const myProjectRequest = request.defaults({
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
Expand All @@ -66,7 +64,7 @@ describe("endpoint.defaults()", () => {
},
org: "my-project",
request: {
fetch: mock,
fetch: mock.fetchHandler,
},
});
const myProjectRequestWithAuth = myProjectRequest.defaults({
Expand Down
Loading

0 comments on commit 2baa69b

Please sign in to comment.