Skip to content

Commit

Permalink
chore(deps): update dependency fetch-mock to v12 (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
renovate[bot] authored Jan 8, 2025
1 parent 5ad12fd commit 751b522
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 62 deletions.
89 changes: 39 additions & 50 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 @@ -48,7 +48,7 @@
"@types/node": "^22.0.0",
"@vitest/coverage-v8": "^2.0.3",
"esbuild": "^0.24.0",
"fetch-mock": "^11.0.0",
"fetch-mock": "^12.0.0",
"glob": "^11.0.0",
"nock": "^14.0.0-beta.8",
"prettier": "^3.2.4",
Expand Down
19 changes: 10 additions & 9 deletions test/integration/smoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,32 @@ describe("Smoke tests", () => {

it("userAgent option", () => {
const mock = fetchMock
.sandbox()
.getOnce("https://api.github.com/", (_url, { headers }) => {
// @ts-ignore headers has wrong typing in fetch-mock 8.3.2
expect(headers["user-agent"]).toMatch(/^my-app\/1.2.3 /);
.createInstance()
.getOnce("https://api.github.com/", (_url) => {
expect(
mock.callHistory.calls()[0].options.headers!["user-agent"],
).toMatch(/^my-app\/1.2.3 /);

return { ok: true };
});

const octokit = new Octokit({
userAgent: "my-app/1.2.3",
request: {
fetch: mock,
fetch: mock.fetchHandler,
},
});
return octokit.request("/");
});

it("@octokit/plugin-rest-endpoint-methods", () => {
const mock = fetchMock
.sandbox()
.createInstance()
.getOnce("path:/repos/octocat/hello-world", { ok: true });

const octokit = new Octokit({
request: {
fetch: mock,
fetch: mock.fetchHandler,
},
});

Expand All @@ -58,7 +59,7 @@ describe("Smoke tests", () => {

it("@octokit/plugin-request-log", () => {
const mock = fetchMock
.sandbox()
.createInstance()
.getOnce("path:/", { status: 200, body: {} })
.getOnce("path:/", { status: 404, body: {} }, { overwriteRoutes: false });

Expand All @@ -72,7 +73,7 @@ describe("Smoke tests", () => {
const octokit = new Octokit({
log: consoleStub,
request: {
fetch: mock,
fetch: mock.fetchHandler,
},
});

Expand Down
4 changes: 2 additions & 2 deletions test/issues/881-redirect-url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe("https://github.com/octokit/rest.js/issues/881", () => {
"https://issue-881-codeload.github.com/octocat/Hello-World/legacy.tar.gz/master";

const mock = fetchMock
.sandbox()
.createInstance()
.headOnce(
"https://api.github.com/repos/octocat/Hello-World/tarball/master",
{
Expand All @@ -20,7 +20,7 @@ describe("https://github.com/octokit/rest.js/issues/881", () => {

const octokit = new Octokit({
request: {
fetch: mock,
fetch: mock.fetchHandler,
},
});

Expand Down

0 comments on commit 751b522

Please sign in to comment.