Skip to content

Commit

Permalink
Fix Danger comment detection
Browse files Browse the repository at this point in the history
  • Loading branch information
cysp committed Dec 26, 2018
1 parent 9d3b826 commit 8cc4b22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/platforms/github/GitHubAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class GitHubAPI {
return allComments
.filter(comment => comment.body.includes(dangerIDMessage)) // does it contain the right danger ID?
.filter(comment => comment.user.id === userID) // Does it have the right user ID?
.filter(comment => comment.body.include("Generated by")) // Does it look like a danger message?
.filter(comment => comment.body.includes("Generated by")) // Does it look like a danger message?
.map(comment => comment.id) // only return IDs
}

Expand Down
9 changes: 9 additions & 0 deletions source/platforms/github/_tests/_github_api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ describe("API testing", () => {
})
})

it("getDangerCommentIDs ignores comments not marked as generated", async () => {
api.getAllOfResource = await requestWithFixturedJSON("github_inline_comments_with_danger.json")
api.getUserID = () => new Promise<number>(r => r(20229914))

const commentIDs = await api.getDangerCommentIDs("default")

expect(commentIDs.length).toEqual(0)
})

it("getPullRequestInlineComment gets only comments for given DangerId", async () => {
api.getAllOfResource = await requestWithFixturedJSON("github_inline_comments_with_danger.json")
api.getUserID = () => new Promise<number>(r => r(20229914))
Expand Down

0 comments on commit 8cc4b22

Please sign in to comment.