Skip to content

Commit

Permalink
fix: jest
Browse files Browse the repository at this point in the history
  • Loading branch information
sshivaditya committed Dec 12, 2024
1 parent 6f470ff commit cfee1b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
8 changes: 8 additions & 0 deletions tests/__mocks__/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ export function createMockAdapters(context: Context) {

return [];
}),
findSimilarIssuesToMatch: jest.fn(async (params: { markdown: string; threshold: number; currentId: string }) => {
if (params.currentId === "task_complete") {
return [{ id: "similar3", similarity: 0.98 }];
} else if (params.currentId === "task_complete_always") {
return [{ id: "similar5", similarity: 0.5 }];
}
return [];
}),
createIssue: jest.fn(async (issue: IssueData) => {
issueMap.set(issue.id, issue);
}),
Expand Down
10 changes: 0 additions & 10 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,6 @@ describe("Plugin tests", () => {
);
});

// Mock the findSimilarIssues function to return predefined similar issues
context.adapters.supabase.issue.findSimilarIssues = jest
.fn<typeof context.adapters.supabase.issue.findSimilarIssues>()
.mockResolvedValue([{ id: "similar3", similarity: 0.98 }] as unknown as IssueSimilaritySearchResult[]);

// Mock the graphql function to return predefined issue data
context.octokit.graphql = jest.fn<typeof context.octokit.graphql>().mockResolvedValue({
node: {
Expand Down Expand Up @@ -339,11 +334,6 @@ describe("Plugin tests", () => {
);
});

// Mock findSimilarIssues to return a result with low similarity
context.adapters.supabase.issue.findSimilarIssues = jest
.fn<typeof context.adapters.supabase.issue.findSimilarIssues>()
.mockResolvedValue([{ id: "similar5", similarity: 0.5 }] as unknown as IssueSimilaritySearchResult[]);

// Mock graphql to return issue data with a contributor
context.octokit.graphql = jest.fn<typeof context.octokit.graphql>().mockResolvedValue({
node: {
Expand Down

0 comments on commit cfee1b7

Please sign in to comment.