mirror of
https://github.com/mshick/add-pr-comment.git
synced 2026-01-01 14:49:44 +11:00
parent
ef723874d4
commit
a251f051d3
9 changed files with 154 additions and 85 deletions
|
|
@ -30,6 +30,7 @@ type Inputs = {
|
|||
'message-cancelled'?: string
|
||||
'message-skipped'?: string
|
||||
'update-only'?: string
|
||||
preformatted?: string
|
||||
status?: 'success' | 'failure' | 'cancelled' | 'skipped'
|
||||
}
|
||||
|
||||
|
|
@ -41,6 +42,7 @@ const defaultInputs: Inputs = {
|
|||
'repo-token': repoToken,
|
||||
'message-id': 'add-pr-comment',
|
||||
'allow-repeats': 'false',
|
||||
status: 'success',
|
||||
}
|
||||
|
||||
const defaultIssueNumber = 1
|
||||
|
|
@ -95,10 +97,10 @@ const server = setupServer(...handlers)
|
|||
|
||||
describe('add-pr-comment action', () => {
|
||||
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(() => {})
|
||||
// vi.spyOn(core, 'debug').mockImplementation(() => {})
|
||||
// vi.spyOn(core, 'info').mockImplementation(() => {})
|
||||
// vi.spyOn(core, 'warning').mockImplementation(() => {})
|
||||
server.listen({ onUnhandledRequest: 'error' })
|
||||
})
|
||||
afterAll(() => server.close())
|
||||
|
|
@ -392,4 +394,17 @@ describe('add-pr-comment action', () => {
|
|||
await run()
|
||||
expect(messagePayload?.body).toContain('666')
|
||||
})
|
||||
|
||||
it('wraps a message in a codeblock if preformatted is true', async () => {
|
||||
inputs.message = undefined
|
||||
inputs['preformatted'] = 'true'
|
||||
inputs['message-path'] = messagePath1Fixture
|
||||
|
||||
await expect(run()).resolves.not.toThrow()
|
||||
expect(
|
||||
`<!-- add-pr-comment:add-pr-comment -->\n\n\`\`\`\n${messagePath1FixturePayload}\n\`\`\``,
|
||||
).toEqual(messagePayload?.body)
|
||||
expect(core.setOutput).toHaveBeenCalledWith('comment-created', 'true')
|
||||
expect(core.setOutput).toHaveBeenCalledWith('comment-id', postIssueCommentsResponse.id)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue