Skip to content

Commit 5d7ea46

Browse files
authored
Merge pull request #26 from GrantBirki/trim-body
Trim the comment body
2 parents 4e20a30 + ee4dff0 commit 5d7ea46

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

__tests__/main.test.js

+23
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,29 @@ test('successfully runs the action in noop mode', async () => {
114114
expect(saveStateMock).toHaveBeenCalledWith('noop', 'true')
115115
})
116116

117+
test('successfully runs the action after trimming the body', async () => {
118+
jest.spyOn(prechecks, 'prechecks').mockImplementation(comment => {
119+
expect(comment).toBe('.deploy noop')
120+
121+
return {
122+
ref: 'test-ref',
123+
status: true,
124+
message: '✔️ PR is approved and all CI checks passed - OK',
125+
noopMode: true
126+
}
127+
})
128+
github.context.payload = {
129+
issue: {
130+
number: 123
131+
},
132+
comment: {
133+
body: '.deploy noop \n\t\n '
134+
}
135+
}
136+
expect(await run()).toBe('success - noop')
137+
// other expects are similar to previous tests.
138+
})
139+
117140
test('successfully runs the action with required contexts', async () => {
118141
process.env.INPUT_REQUIRED_CONTEXTS = 'lint,test,build'
119142
expect(await run()).toBe('success')

dist/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export async function run() {
3434
}
3535

3636
// Get variables from the event context
37-
const body = context.payload.comment.body
37+
const body = context.payload.comment.body.trim()
3838
const issue_number = context.payload.issue.number
3939
const {owner, repo} = context.repo
4040

0 commit comments

Comments
 (0)