Skip to content

Commit

Permalink
chore: test handlers - add readme fetch, stats - fix openai resp
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Oct 25, 2024
1 parent 49c9dcd commit 96f98af
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/__mocks__/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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"),
})
),
];

0 comments on commit 96f98af

Please sign in to comment.