mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2026-04-20 13:05:44 +00:00
Add prefix and suffix inputs to wrap comment body
Co-authored-by: marocchino <128431+marocchino@users.noreply.github.com>
This commit is contained in:
parent
58d8e91c23
commit
5b837e833d
4 changed files with 87 additions and 2 deletions
|
|
@ -210,4 +210,49 @@ describe("getBody", () => {
|
|||
expect(await config.getBody()).toBe("")
|
||||
expect(core.setFailed).toHaveBeenCalledWith("glob error")
|
||||
})
|
||||
|
||||
test("wraps message with prefix and suffix", async () => {
|
||||
const {config, core} = await loadConfig()
|
||||
vi.mocked(core.getInput).mockImplementation(name => {
|
||||
if (name === "message") return "hello there"
|
||||
if (name === "prefix") return "```"
|
||||
if (name === "suffix") return "```"
|
||||
return ""
|
||||
})
|
||||
expect(await config.getBody()).toBe("```\nhello there\n```")
|
||||
})
|
||||
|
||||
test("wraps file content with prefix and suffix", async () => {
|
||||
const {config, core} = await loadConfig()
|
||||
vi.mocked(core.getMultilineInput).mockReturnValue(["__tests__/assets/result"])
|
||||
vi.mocked(core.getInput).mockImplementation(name => {
|
||||
if (name === "prefix") return "```"
|
||||
if (name === "suffix") return "```"
|
||||
return ""
|
||||
})
|
||||
mockGlobCreate.mockResolvedValue({
|
||||
glob: vi.fn().mockResolvedValue([resolve("__tests__/assets/result")]),
|
||||
})
|
||||
expect(await config.getBody()).toBe("```\nhi there\n\n```")
|
||||
})
|
||||
|
||||
test("applies only prefix when suffix is not provided", async () => {
|
||||
const {config, core} = await loadConfig()
|
||||
vi.mocked(core.getInput).mockImplementation(name => {
|
||||
if (name === "message") return "hello there"
|
||||
if (name === "prefix") return "```"
|
||||
return ""
|
||||
})
|
||||
expect(await config.getBody()).toBe("```\nhello there")
|
||||
})
|
||||
|
||||
test("applies only suffix when prefix is not provided", async () => {
|
||||
const {config, core} = await loadConfig()
|
||||
vi.mocked(core.getInput).mockImplementation(name => {
|
||||
if (name === "message") return "hello there"
|
||||
if (name === "suffix") return "```"
|
||||
return ""
|
||||
})
|
||||
expect(await config.getBody()).toBe("hello there\n```")
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue