add option to delete the previous comment and create a new one

This commit is contained in:
Jake Hiller 2020-06-23 11:45:02 -04:00
parent 7235ddcfc1
commit 2f6d0e21be
4 changed files with 49 additions and 7 deletions

View file

@ -1,7 +1,8 @@
import {
findPreviousComment,
createComment,
updateComment
updateComment,
deleteComment
} from "../src/comment";
const repo = {};
it("findPreviousComment", async () => {
@ -97,3 +98,30 @@ it("createComment", async () => {
body: "<!-- Sticky Pull Request CommentTypeA -->\nhello there"
});
});
it("removeComment", async () => {
const octokit = {
issues: {
deleteComment: jest.fn(() => Promise.resolve())
}
};
expect(
await deleteComment(octokit, repo, 456)
).toBeUndefined();
expect(octokit.issues.deleteComment).toBeCalledWith({
comment_id: 456
});
expect(
await deleteComment(octokit, repo, 456)
).toBeUndefined();
expect(octokit.issues.deleteComment).toBeCalledWith({
comment_id: 456
});
expect(
await deleteComment(octokit, repo, 456)
).toBeUndefined();
expect(octokit.issues.deleteComment).toBeCalledWith({
comment_id: 456
});
});