Skip to content

Commit

Permalink
chore: refactor test event payload
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Aug 24, 2024
1 parent 0dcc361 commit 7625c17
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,16 @@ function daysPriorToNow(days: number) {
return new Date(Date.now() - ONE_DAY * days).toISOString();
}

function createContext(issueId: number, senderId: number): Context {
function createContext(issueId: number, senderId: number): Context<"issue_comment.created"> {
return {
payload: {
issue: db.issue.findFirst({ where: { id: { equals: issueId } } }) as unknown as Context["payload"]["issue"],
sender: db.users.findFirst({ where: { id: { equals: senderId } } }) as unknown as Context["payload"]["sender"],
repository: db.repo.findFirst({ where: { id: { equals: 1 } } }) as unknown as Context["payload"]["repository"],
action: "assigned",
issue: db.issue.findFirst({ where: { id: { equals: issueId } } }) as unknown as Context<"issue_comment.created">["payload"]["issue"],
sender: db.users.findFirst({ where: { id: { equals: senderId } } }) as unknown as Context<"issue_comment.created">["payload"]["sender"],
repository: db.repo.findFirst({ where: { id: { equals: 1 } } }) as unknown as Context<"issue_comment.created">["payload"]["repository"],
action: "created",
installation: { id: 1 } as unknown as Context["payload"]["installation"],
organization: { login: STRINGS.UBIQUITY } as unknown as Context["payload"]["organization"],
comment: db.issueComments.findFirst({ where: { issueId: { equals: issueId } } }) as unknown as Context<"issue_comment.created">["payload"]["comment"],
},
logger: new Logs("debug"),
config: {
Expand All @@ -220,6 +221,6 @@ function createContext(issueId: number, senderId: number): Context {
watch: { optOut: [STRINGS.PRIVATE_REPO_NAME] },
},
octokit: new octokit.Octokit(),
eventName: "issues.assigned",
eventName: "issue_comment.created",
};
}

0 comments on commit 7625c17

Please sign in to comment.