@@ -7,7 +7,7 @@ import {COLORS} from '../../src/functions/colors'
7
7
8
8
const setOutputMock = jest . spyOn ( core , 'setOutput' )
9
9
const infoMock = jest . spyOn ( core , 'info' )
10
- const setFailedMock = jest . spyOn ( core , 'setFailed ' )
10
+ const warningMock = jest . spyOn ( core , 'warning ' )
11
11
const debugMock = jest . spyOn ( core , 'debug' )
12
12
13
13
const environment_targets = 'production,development,staging'
@@ -16,7 +16,7 @@ var context
16
16
var octokit
17
17
beforeEach ( ( ) => {
18
18
jest . clearAllMocks ( )
19
- jest . spyOn ( core , 'setFailed ' ) . mockImplementation ( ( ) => { } )
19
+ jest . spyOn ( core , 'warning ' ) . mockImplementation ( ( ) => { } )
20
20
jest . spyOn ( core , 'setOutput' ) . mockImplementation ( ( ) => { } )
21
21
jest . spyOn ( core , 'info' ) . mockImplementation ( ( ) => { } )
22
22
jest . spyOn ( core , 'debug' ) . mockImplementation ( ( ) => { } )
@@ -148,7 +148,25 @@ test('fails due to the context not being a PR merge', async () => {
148
148
expect ( infoMock ) . toHaveBeenCalledWith (
149
149
'event name: pull_request, action: opened, merged: false'
150
150
)
151
- expect ( setFailedMock ) . toHaveBeenCalledWith (
152
- 'this workflow can only run in the context of a merged pull request'
151
+ expect ( warningMock ) . toHaveBeenCalledWith (
152
+ `this workflow can only run in the context of a ${ COLORS . highlight } merged${ COLORS . reset } pull request`
153
+ )
154
+ } )
155
+
156
+ test ( 'fails due to the context being a PR closed event but not a merge' , async ( ) => {
157
+ context . payload . action = 'closed'
158
+ context . payload . pull_request . merged = false
159
+ context . payload . eventName = 'pull_request'
160
+ expect (
161
+ await unlockOnMerge ( octokit , context , environment_targets )
162
+ ) . toStrictEqual ( false )
163
+ expect ( warningMock ) . toHaveBeenCalledWith (
164
+ `this workflow can only run in the context of a ${ COLORS . highlight } merged${ COLORS . reset } pull request`
165
+ )
166
+ expect ( infoMock ) . toHaveBeenCalledWith (
167
+ 'event name: pull_request, action: closed, merged: false'
168
+ )
169
+ expect ( infoMock ) . toHaveBeenCalledWith (
170
+ 'pull request was closed but not merged so this workflow will not run - OK'
153
171
)
154
172
} )
0 commit comments