Add option to skip updating or recreating comments when message is unchanged

This commit is contained in:
Alex Burgel 2023-08-14 12:51:55 -04:00
parent 077277a006
commit e5439e773a
No known key found for this signature in database
6 changed files with 96 additions and 19 deletions

View file

@ -7,7 +7,8 @@ import {
findPreviousComment,
getBodyOf,
updateComment,
minimizeComment
minimizeComment,
commentsEqual
} from "../src/comment"
jest.mock("@actions/core", () => ({
@ -250,3 +251,16 @@ describe("getBodyOf", () => {
}
)
})
describe("commentsEqual", () => {
test.each([
{ body: "body", previous: "body\n<!-- Sticky Pull Request Commentheader -->", header: "header", expected: true },
{ body: "body", previous: "body\n<!-- Sticky Pull Request Comment -->", header: "", expected: true },
{ body: "body", previous: "body\n<!-- Sticky Pull Request Commenta different header -->", header: "header", expected: false },
{ body: "body", previous: "body", header: "header", expected: false },
{ body: "body", previous: "", header: "header", expected: false },
{ body: "", previous: "body", header: "header", expected: false },
])("commentsEqual(%s, %s, %s)", ({body, previous, header, expected}) => {
expect(commentsEqual(body, previous, header)).toEqual(expected)
})
})