mirror of
https://github.com/mshick/add-pr-comment.git
synced 2025-12-31 14:20:32 +11:00
update replace behavior
This commit is contained in:
parent
25e7c93662
commit
ff82b38f95
3 changed files with 36 additions and 5 deletions
|
|
@ -97,10 +97,7 @@ const handlers = [
|
|||
const server = setupServer(...handlers)
|
||||
|
||||
beforeAll(() => {
|
||||
// vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
// vi.spyOn(core, 'debug').mockImplementation(() => {})
|
||||
// vi.spyOn(core, 'info').mockImplementation(() => {})
|
||||
// vi.spyOn(core, 'warning').mockImplementation(() => {})
|
||||
vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
server.listen({ onUnhandledRequest: 'error' })
|
||||
})
|
||||
afterAll(() => server.close())
|
||||
|
|
@ -517,6 +514,35 @@ describe('find and replace', () => {
|
|||
expect(core.setOutput).toHaveBeenCalledWith('comment-id', commentId)
|
||||
})
|
||||
|
||||
it('can multiple find and replace a single pattern with a multiline replacement', async () => {
|
||||
inputs['find'] = 'hello'
|
||||
inputs['message'] = 'h\ne\nl\nl\no'
|
||||
|
||||
const body = `<!-- add-pr-comment:${inputs['message-id']} -->\n\nhello\nworld`
|
||||
|
||||
const commentId = 123
|
||||
|
||||
const replyBody = [
|
||||
{
|
||||
id: commentId,
|
||||
body,
|
||||
},
|
||||
]
|
||||
|
||||
getIssueCommentsResponse = replyBody
|
||||
postIssueCommentsResponse = {
|
||||
id: commentId,
|
||||
}
|
||||
|
||||
await run()
|
||||
|
||||
expect(`<!-- add-pr-comment:add-pr-comment -->\n\nh\ne\nl\nl\no\nworld`).toEqual(
|
||||
messagePayload?.body,
|
||||
)
|
||||
expect(core.setOutput).toHaveBeenCalledWith('comment-updated', 'true')
|
||||
expect(core.setOutput).toHaveBeenCalledWith('comment-id', commentId)
|
||||
})
|
||||
|
||||
it('can multiple find and replace text using a message-path', async () => {
|
||||
inputs['find'] = '<< FILE_CONTENTS >>'
|
||||
inputs['message-path'] = messagePath1Fixture
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue