Hide details (#435)

*  hide details

* 📦 build

* 👷 ci for hide_details option
This commit is contained in:
marocchino 2021-09-29 03:15:07 +09:00 committed by GitHub
parent 53e089cfe2
commit 21a90c1106
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 136 additions and 8 deletions

View file

@ -5,6 +5,7 @@ import {
createComment,
deleteComment,
findPreviousComment,
getBodyOf,
updateComment
} from "../src/comment"
@ -177,3 +178,42 @@ it("deleteComment", async () => {
repo: "sticky-pull-request-comment"
})
})
describe("getBodyOf", () => {
const nullPrevious = {}
const simplePrevious = {
body: "hello there\n<!-- Sticky Pull Request CommentTypeA -->"
}
const detailsPrevious = {
body: `
<details open>
<summary>title</summary>
content
</details>
<!-- Sticky Pull Request CommentTypeA -->
`
}
const replaced = `
<details>
<summary>title</summary>
content
</details>
<!-- Sticky Pull Request CommentTypeA -->
`
test.each`
append | hideDetails | previous | expected
${false} | ${false} | ${detailsPrevious} | ${undefined}
${true} | ${false} | ${nullPrevious} | ${undefined}
${true} | ${false} | ${detailsPrevious} | ${detailsPrevious.body}
${true} | ${true} | ${nullPrevious} | ${undefined}
${true} | ${true} | ${simplePrevious} | ${simplePrevious.body}
${true} | ${true} | ${detailsPrevious} | ${replaced}
`(
"receive $previous, $append, $hideDetails and returns $expected",
({append, hideDetails, previous, expected}) => {
expect(getBodyOf(previous, append, hideDetails)).toEqual(expected)
}
)
})