Skip to content

Commit 2745691

Browse files
tests to cover trigger cases
1 parent e3afe24 commit 2745691

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

__tests__/functions/trigger-check.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,24 @@ test('checks a message and does not find global trigger', async () => {
5252
`comment body does not start with trigger: ${color}.deploy${colorReset}`
5353
)
5454
})
55+
56+
test('does not match when body starts with a longer command sharing prefix', async () => {
57+
const body = '.deploy-two to prod'
58+
const trigger = '.deploy'
59+
expect(await triggerCheck(body, trigger)).toBe(false)
60+
expect(debugMock).toHaveBeenCalledWith(
61+
`comment body starts with trigger but is not complete: ${color}.deploy${colorReset}`
62+
)
63+
})
64+
65+
test('does not match when immediately followed by alphanumeric', async () => {
66+
const body = '.deploy1'
67+
const trigger = '.deploy'
68+
expect(await triggerCheck(body, trigger)).toBe(false)
69+
})
70+
71+
test('matches when followed by a newline (whitespace)', async () => {
72+
const body = `.deploy\ndev`
73+
const trigger = '.deploy'
74+
expect(await triggerCheck(body, trigger)).toBe(true)
75+
})

0 commit comments

Comments
 (0)