From 96f98af66aae4fdbe68a5287a04ca01934ec8df4 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Fri, 25 Oct 2024 19:47:38 +0100 Subject: [PATCH] chore: test handlers - add readme fetch, stats - fix openai resp --- tests/__mocks__/handlers.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/__mocks__/handlers.ts b/tests/__mocks__/handlers.ts index 20503d9..be7ba62 100644 --- a/tests/__mocks__/handlers.ts +++ b/tests/__mocks__/handlers.ts @@ -7,7 +7,7 @@ import issueTemplate from "./issue-template"; */ export const handlers = [ http.post("https://api.openai.com/v1/chat/completions", () => { - const answer = `This is a mock answer for the chat`; + const answer = `${JSON.stringify(["This is a mock response from OpenAI"])}`; return HttpResponse.json({ usage: { @@ -85,4 +85,16 @@ export const handlers = [ db.pull.findFirst({ where: { owner: { equals: owner as string }, repo: { equals: repo as string }, number: { equals: Number(pullNumber) } } }) ) ), + http.get("https://api.github.com/repos/:owner/:repo/languages", ({ params: { owner, repo } }) => + HttpResponse.json(db.repo.findFirst({ where: { owner: { login: { equals: owner as string } }, name: { equals: repo as string } } })) + ), + http.get("https://api.github.com/repos/:owner/:repo/contents/:path", () => + HttpResponse.json({ + type: "file", + encoding: "base64", + size: 5362, + name: "README.md", + content: Buffer.from(JSON.stringify({ content: "This is a mock README file" })).toString("base64"), + }) + ), ];