diff --git a/src/api.test.ts b/src/api.test.ts index 8e38781..af0a8d1 100644 --- a/src/api.test.ts +++ b/src/api.test.ts @@ -65,9 +65,23 @@ test("comments API ", async () => { }); test("mentions in issue", async () => { - expect(await api.findMentionsInIssue(username, repo, 1)).toBe(true); - expect(await api.findMentionsInIssue(username, repo, 2)).toBe(true); - expect(await api.findMentionsInIssue(username, repo, 3)).toBe(true); - expect(await api.findMentionsInIssue(username, repo, 4)).toBe(true); - expect(await api.findMentionsInIssue(username, repo, 5)).toBe(false); + let issue = await api.getIssue(username, repo, 1); + issue = await api.getCommentsForIssue(issue); + expect(await api.findMentionsInIssue(issue)).toBe(true); + + issue = await api.getIssue(username, repo, 2); + issue = await api.getCommentsForIssue(issue); + expect(await api.findMentionsInIssue(issue)).toBe(true); + + issue = await api.getIssue(username, repo, 3); + issue = await api.getCommentsForIssue(issue); + expect(await api.findMentionsInIssue(issue)).toBe(true); + + issue = await api.getIssue(username, repo, 4); + issue = await api.getCommentsForIssue(issue); + expect(await api.findMentionsInIssue(issue)).toBe(true); + + issue = await api.getIssue(username, repo, 5); + issue = await api.getCommentsForIssue(issue); + expect(await api.findMentionsInIssue(issue)).toBe(false); }); diff --git a/src/index.ts b/src/index.ts index 4bfef7c..9b6e8fd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -117,9 +117,7 @@ class Forgejo { /** * Check if logged in user is mentioned in the issue */ - async findMentionsInIssue(owner: string, repo: string, id: number) { - let issue = await this.getIssue(owner, repo, id); - issue = await this.getCommentsForIssue(issue); + async findMentionsInIssue(issue: Issue) { let unreadTime = this.lastReadTime(issue); const mentionUtil = (str: string): boolean => {