Skip to content

Commit

Permalink
fix: fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sshivaditya committed Oct 10, 2024
1 parent 4bce42c commit 3477aea
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function returnDataToKernel(repoToken: string, stateId: string, output: ob
await octokit.repos.createDispatchEvent({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
event_type: "return_data_to_ubiquibot_kernel",
event_type: "return-data-to-ubiquity-os-kernel",
client_payload: {
state_id: stateId,
output: JSON.stringify(output),
Expand Down
36 changes: 22 additions & 14 deletions tests/__mocks__/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,29 @@ export function createMockAdapters(context: Context) {
commentMap.set(commentNodeId, { id: commentNodeId, plaintext, author_id: authorId, embedding, issue_id: issueId });
}
),
updateComment: jest.fn(async (plaintext: string | null, commentNodeId: string, payload: Record<string, unknown> | null, isPrivate: boolean) => {
if (!commentMap.has(commentNodeId)) {
throw new Error(STRINGS.COMMENT_DOES_NOT_EXIST);
}
const originalComment = commentMap.get(commentNodeId);
if (!originalComment) {
throw new Error(STRINGS.COMMENT_DOES_NOT_EXIST);
}
const { id, author_id } = originalComment;
const embedding = await context.adapters.voyage.embedding.createEmbedding(plaintext);
if (isPrivate) {
plaintext = null;
updateComment: jest.fn(
async (
plaintext: string | null,
commentNodeId: string,
authorId: number,
payload: Record<string, unknown> | null,
isPrivate: boolean,
issueId: string
) => {
if (!commentMap.has(commentNodeId)) {
throw new Error(STRINGS.COMMENT_DOES_NOT_EXIST);
}
const originalComment = commentMap.get(commentNodeId);
if (!originalComment) {
throw new Error(STRINGS.COMMENT_DOES_NOT_EXIST);
}
const embedding = await context.adapters.voyage.embedding.createEmbedding(plaintext);
if (isPrivate) {
plaintext = null;
}
commentMap.set(commentNodeId, { id: issueId, plaintext, author_id: authorId, embedding, payload });
}
commentMap.set(commentNodeId, { id, plaintext, author_id, embedding });
}),
),
deleteComment: jest.fn(async (commentNodeId: string) => {
if (!commentMap.has(commentNodeId)) {
throw new Error(STRINGS.COMMENT_DOES_NOT_EXIST);
Expand Down

0 comments on commit 3477aea

Please sign in to comment.