Skip to content

Commit

Permalink
test: adapt code for fetch-mock v12
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfy1339 committed Jan 8, 2025
1 parent b832e02 commit a4f9120
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions test/integration/smoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("Smoke tests", () => {

it("userAgent option", () => {
const mock = fetchMock
.sandbox()
.createInstance()
.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 /);
Expand All @@ -27,20 +27,20 @@ describe("Smoke tests", () => {
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 +58,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 +72,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 a4f9120

Please sign in to comment.