mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2025-12-16 05:06:31 +00:00
test: find & write with comment header
This commit is contained in:
parent
5a3fa9621f
commit
0c015d9eea
1 changed files with 12 additions and 7 deletions
|
|
@ -4,17 +4,18 @@ import {
|
||||||
updateComment
|
updateComment
|
||||||
} from "../src/comment";
|
} from "../src/comment";
|
||||||
const repo = {};
|
const repo = {};
|
||||||
const body = "some message";
|
|
||||||
it("findPreviousComment", async () => {
|
it("findPreviousComment", async () => {
|
||||||
const comment = {
|
const comment = {
|
||||||
user: {
|
user: {
|
||||||
login: "github-actions[bot]"
|
login: "github-actions[bot]"
|
||||||
}
|
},
|
||||||
|
body: "<!-- Sticky Pull Request Comment -->\nprevious message"
|
||||||
};
|
};
|
||||||
const otherComment = {
|
const otherComment = {
|
||||||
user: {
|
user: {
|
||||||
login: "some-user"
|
login: "some-user"
|
||||||
}
|
},
|
||||||
|
body: "lgtm"
|
||||||
};
|
};
|
||||||
const octokit = {
|
const octokit = {
|
||||||
issues: {
|
issues: {
|
||||||
|
|
@ -35,10 +36,12 @@ it("updateComment", async () => {
|
||||||
updateComment: jest.fn(() => Promise.resolve())
|
updateComment: jest.fn(() => Promise.resolve())
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
expect(await updateComment(octokit, repo, 456, body)).toBeUndefined();
|
expect(
|
||||||
|
await updateComment(octokit, repo, 456, "hello there")
|
||||||
|
).toBeUndefined();
|
||||||
expect(octokit.issues.updateComment).toBeCalledWith({
|
expect(octokit.issues.updateComment).toBeCalledWith({
|
||||||
comment_id: 456,
|
comment_id: 456,
|
||||||
body
|
body: "<!-- Sticky Pull Request Comment -->\nhello there"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("createComment", async () => {
|
it("createComment", async () => {
|
||||||
|
|
@ -47,9 +50,11 @@ it("createComment", async () => {
|
||||||
createComment: jest.fn(() => Promise.resolve())
|
createComment: jest.fn(() => Promise.resolve())
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
expect(await createComment(octokit, repo, 456, body)).toBeUndefined();
|
expect(
|
||||||
|
await createComment(octokit, repo, 456, "hello there")
|
||||||
|
).toBeUndefined();
|
||||||
expect(octokit.issues.createComment).toBeCalledWith({
|
expect(octokit.issues.createComment).toBeCalledWith({
|
||||||
issue_number: 456,
|
issue_number: 456,
|
||||||
body
|
body: "<!-- Sticky Pull Request Comment -->\nhello there"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue