Skip to content

Commit

Permalink
Merge pull request #26 from GrantBirki/trim-body
Browse files Browse the repository at this point in the history
Trim the comment body
  • Loading branch information
GrantBirki authored May 27, 2022
2 parents 4e20a30 + ee4dff0 commit 5d7ea46
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
23 changes: 23 additions & 0 deletions __tests__/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,29 @@ test('successfully runs the action in noop mode', async () => {
expect(saveStateMock).toHaveBeenCalledWith('noop', 'true')
})

test('successfully runs the action after trimming the body', async () => {
jest.spyOn(prechecks, 'prechecks').mockImplementation(comment => {
expect(comment).toBe('.deploy noop')

return {
ref: 'test-ref',
status: true,
message: '✔️ PR is approved and all CI checks passed - OK',
noopMode: true
}
})
github.context.payload = {
issue: {
number: 123
},
comment: {
body: '.deploy noop \n\t\n '
}
}
expect(await run()).toBe('success - noop')
// other expects are similar to previous tests.
})

test('successfully runs the action with required contexts', async () => {
process.env.INPUT_REQUIRED_CONTEXTS = 'lint,test,build'
expect(await run()).toBe('success')
Expand Down
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/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export async function run() {
}

// Get variables from the event context
const body = context.payload.comment.body
const body = context.payload.comment.body.trim()
const issue_number = context.payload.issue.number
const {owner, repo} = context.repo

Expand Down

0 comments on commit 5d7ea46

Please sign in to comment.