Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update dependency fetch-mock to v12 #707

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 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 @@ -46,7 +46,7 @@
"@types/sinonjs__fake-timers": "^8.1.5",
"@vitest/coverage-v8": "^2.1.1",
"esbuild": "^0.24.0",
"fetch-mock": "^11.0.0",
"fetch-mock": "^12.0.0",
"glob": "^11.0.0",
"prettier": "3.3.3",
"proxy": "^2.0.0",
Expand Down
42 changes: 21 additions & 21 deletions test/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ beforeEach(() => {

describe("Authentication", () => {
it("new Octokit({ auth: 'secret123' })", () => {
const mock = fetchMock.sandbox().getOnce(
const mock = fetchMock.createInstance().getOnce(
"https://api.github.com/",
{ ok: true },
{
Expand All @@ -80,15 +80,15 @@ describe("Authentication", () => {
const octokit = new Octokit({
auth: "secret123",
request: {
fetch: mock,
fetch: mock.fetchHandler,
},
});

return octokit.request("/");
});

it("new Octokit({ auth: 'token secret123' })", () => {
const mock = fetchMock.sandbox().getOnce(
const mock = fetchMock.createInstance().getOnce(
"https://api.github.com/",
{ ok: true },
{
Expand All @@ -103,15 +103,15 @@ describe("Authentication", () => {
const octokit = new Octokit({
auth: "token secret123",
request: {
fetch: mock,
fetch: mock.fetchHandler,
},
});

return octokit.request("/");
});

it("new Octokit({ auth: 'Token secret123' })", () => {
const mock = fetchMock.sandbox().getOnce(
const mock = fetchMock.createInstance().getOnce(
"https://api.github.com/",
{ ok: true },
{
Expand All @@ -126,7 +126,7 @@ describe("Authentication", () => {
const octokit = new Octokit({
auth: "Token secret123",
request: {
fetch: mock,
fetch: mock.fetchHandler,
},
});

Expand All @@ -136,7 +136,7 @@ describe("Authentication", () => {
const BEARER_TOKEN =
"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1NTM4MTkzMTIsImV4cCI6MTU1MzgxOTM3MiwiaXNzIjoxfQ.etiSZ4LFQZ8tiMGJVqKDoGn8hxMCgwL4iLvU5xBUqbAPr4pbk_jJZmMQjuxTlOnRxq4e7NouTizGCdfohRMb3R1mpLzGPzOH9_jqSA_BWYxolsRP_WDSjuNcw6nSxrPRueMVRBKFHrqcTOZJej0djRB5pI61hDZJ_-DGtiOIFexlK3iuVKaqBkvJS5-TbTekGuipJ652g06gXuz-l8i0nHiFJldcuIruwn28hTUrjgtPbjHdSBVn_QQLKc2Fhij8OrhcGqp_D_fvb_KovVmf1X6yWiwXV5VXqWARS-JGD9JTAr2495ZlLV_E4WPxdDpz1jl6XS9HUhMuwBpaCOuipw";
it("new Octokit({ auth: BEARER_TOKEN })", () => {
const mock = fetchMock.sandbox().getOnce(
const mock = fetchMock.createInstance().getOnce(
"https://api.github.com/",
{ ok: true },
{
Expand All @@ -151,7 +151,7 @@ describe("Authentication", () => {
const octokit = new Octokit({
auth: BEARER_TOKEN,
request: {
fetch: mock,
fetch: mock.fetchHandler,
},
});

Expand All @@ -163,7 +163,7 @@ describe("Authentication", () => {
const CLIENT_SECRET = "0123secret";
const CODE = "code123";

const mock = fetchMock.sandbox().postOnce(
const mock = fetchMock.createInstance().postOnce(
"https://github.com/login/oauth/access_token",
{
access_token: "token123",
Expand All @@ -182,7 +182,7 @@ describe("Authentication", () => {
const MyOctokit = Octokit.defaults({
authStrategy: createOAuthAppAuth,
request: {
fetch: mock,
fetch: mock.fetchHandler,
},
});

Expand All @@ -198,12 +198,12 @@ describe("Authentication", () => {
code: CODE,
});

expect(mock.done()).toBe(true);
expect(mock.callHistory.done()).toBe(true);
});

it("auth = createAppAuth()", async () => {
const mock = fetchMock
.sandbox()
.createInstance()
.postOnce("https://api.github.com/app/installations/123/access_tokens", {
token: "secret123",
expires_at: "1970-01-01T01:00:00.000Z",
Expand Down Expand Up @@ -242,7 +242,7 @@ describe("Authentication", () => {
installationId: 123,
},
request: {
fetch: mock,
fetch: mock.fetchHandler,
},
});

Expand All @@ -251,11 +251,11 @@ describe("Authentication", () => {

await octokit.request("GET /app");

expect(mock.done()).toBe(true);
expect(mock.callHistory.done()).toBe(true);
});

it("auth = createActionAuth()", async () => {
const mock = fetchMock.sandbox().getOnce(
const mock = fetchMock.createInstance().getOnce(
"https://api.github.com/app",
{ id: 123 },
{
Expand All @@ -275,7 +275,7 @@ describe("Authentication", () => {
const octokit = new Octokit({
authStrategy: createActionAuth,
request: {
fetch: mock,
fetch: mock.fetchHandler,
},
});

Expand Down Expand Up @@ -303,7 +303,7 @@ describe("Authentication", () => {

it("createAppAuth with GraphQL + GHES (probot/probot#1386)", async () => {
const mock = fetchMock
.sandbox()
.createInstance()
.postOnce(
"https://fake.github-enterprise.com/api/v3/app/installations/123/access_tokens",
{
Expand Down Expand Up @@ -334,7 +334,7 @@ describe("Authentication", () => {
},
baseUrl: "https://fake.github-enterprise.com/api/v3",
request: {
fetch: mock,
fetch: mock.fetchHandler,
},
});

Expand All @@ -344,12 +344,12 @@ describe("Authentication", () => {
}
}`);

expect(mock.done()).toBe(true);
expect(mock.callHistory.done()).toBe(true);
});

it("should pass through the logger (#1277)", async () => {
const mock = fetchMock
.sandbox()
.createInstance()
.postOnce("https://api.github.com/app/installations/2/access_tokens", {
token: "installation-token-123",
permissions: {},
Expand Down Expand Up @@ -377,7 +377,7 @@ describe("Authentication", () => {
installationId: 2,
},
request: {
fetch: mock,
fetch: mock.fetchHandler,
},
});

Expand Down
8 changes: 4 additions & 4 deletions test/constructor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { describe, expect, it } from "vitest";

describe("Smoke test", () => {
it("previews option", () => {
const mock = fetchMock.sandbox().getOnce(
const mock = fetchMock.createInstance().getOnce(
"https://api.github.com/graphql",
{ ok: true },
{
Expand All @@ -22,15 +22,15 @@ describe("Smoke test", () => {
"symmetra",
],
request: {
fetch: mock,
fetch: mock.fetchHandler,
},
});

return octokit.request("/graphql");
});

it("timeZone option", () => {
const mock = fetchMock.sandbox().getOnce(
const mock = fetchMock.createInstance().getOnce(
"https://api.github.com/",
{ ok: true },
{
Expand All @@ -44,7 +44,7 @@ describe("Smoke test", () => {
const octokit = new Octokit({
timeZone: "Europe/Amsterdam",
request: {
fetch: mock,
fetch: mock.fetchHandler,
},
});

Expand Down
Loading
Loading