From 96217009359447435787c8878a72f9ac692b594b Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Sun, 12 Jan 2025 15:04:03 +0900 Subject: [PATCH] test: fixed test for collaborator status --- tests/__mocks__/handlers.ts | 5 +++++ tests/pre-check.test.ts | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/__mocks__/handlers.ts b/tests/__mocks__/handlers.ts index 46079be4..56c53c21 100644 --- a/tests/__mocks__/handlers.ts +++ b/tests/__mocks__/handlers.ts @@ -212,4 +212,9 @@ export const handlers = [ http.post("https://api.github.com/repos/:owner/:repo/issues/:id/comments", () => { return HttpResponse.json({}); }), + http.get("https://api.github.com/repos/:owner/:repo/collaborators/:user/permission", () => { + return HttpResponse.json({ + role_name: "admin", + }); + }), ]; diff --git a/tests/pre-check.test.ts b/tests/pre-check.test.ts index 437763c9..fd95222c 100644 --- a/tests/pre-check.test.ts +++ b/tests/pre-check.test.ts @@ -117,7 +117,18 @@ describe("Pre-check tests", () => { collectLinkedMergedPulls: jest.fn(() => []), })); const patchMock = jest.fn(() => HttpResponse.json({})); - server.use(http.patch("https://api.github.com/repos/ubiquity/work.ubq.fi/issues/69", patchMock, { once: true })); + server.use( + http.patch("https://api.github.com/repos/ubiquity/work.ubq.fi/issues/69", patchMock, { once: true }), + http.get( + "https://api.github.com/repos/:owner/:repo/collaborators/:user/permission", + () => { + return HttpResponse.json({ + role_name: "read", + }); + }, + { once: true } + ) + ); const { run } = await import("../src/run"); const result = await run({