Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions __tests__/functions/post.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,33 @@ test('throws an error', async () => {
expect(setFailedMock).toHaveBeenCalledWith('test error')
}
})

test('use reaction specified in input on success', async () => {
const reactionInput = {
status: 'success',
success_reaction: 'rocket'
}
jest.spyOn(core, 'getInput').mockImplementation(name => {
return reactionInput[name]
})
const postReactionsMock = jest.spyOn(postReactions, 'postReactions')

expect(await post()).toBeUndefined()
expect(postReactionsMock).toHaveBeenCalled()
expect(postReactionsMock.mock.calls[0][2]).toBe('rocket')
})

test('use reaction specified in input on failure', async () => {
const reactionInput = {
status: 'failure',
failure_reaction: 'confused'
}
jest.spyOn(core, 'getInput').mockImplementation(name => {
return reactionInput[name]
})
const postReactionsMock = jest.spyOn(postReactions, 'postReactions')

expect(await post()).toBeUndefined()
expect(postReactionsMock).toHaveBeenCalled()
expect(postReactionsMock.mock.calls[0][2]).toBe('confused')
})
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/functions/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function post() {
if (success) {
reaction = core.getInput('success_reaction') || thumbsUp
} else {
reaction = core.getInput('failed_reaction') || thumbsDown
reaction = core.getInput('failure_reaction') || thumbsDown
}

// Update the reactions on the command comment
Expand Down