@@ -33,6 +33,8 @@ test.each([
33
33
} ]
34
34
35
35
await comment . afterValidate ( context , settings , '' , schedulerResult )
36
+ await Helper . flushPromises ( )
37
+
36
38
expect ( context . octokit . issues . createComment . mock . calls . length ) . toBe ( 1 )
37
39
} )
38
40
@@ -49,6 +51,8 @@ test('check that comment created when afterValidate is called with proper parame
49
51
}
50
52
51
53
await comment . afterValidate ( context , settings , '' , result )
54
+ await Helper . flushPromises ( )
55
+
52
56
expect ( context . octokit . issues . createComment . mock . calls . length ) . toBe ( 1 )
53
57
expect ( context . octokit . issues . createComment . mock . calls [ 0 ] [ 0 ] . body ) . toBe ( 'Your run has returned the following status: pass' )
54
58
} )
@@ -64,6 +68,8 @@ test('that comment is created three times when result contain three issues found
64
68
}
65
69
} ]
66
70
await comment . afterValidate ( context , settings , '' , schedulerResult )
71
+ await Helper . flushPromises ( )
72
+
67
73
expect ( context . octokit . issues . createComment . mock . calls . length ) . toBe ( 3 )
68
74
} )
69
75
@@ -93,6 +99,8 @@ test('check that old comments from Mergeable are deleted if they exists', async
93
99
}
94
100
95
101
await comment . afterValidate ( context , settings , '' , result )
102
+ await Helper . flushPromises ( )
103
+
96
104
expect ( context . octokit . issues . deleteComment . mock . calls . length ) . toBe ( 1 )
97
105
expect ( context . octokit . issues . deleteComment . mock . calls [ 0 ] [ 0 ] . comment_id ) . toBe ( '2' )
98
106
} )
@@ -123,6 +131,8 @@ test('check that old comments checks toLowerCase of the Bot name', async () => {
123
131
}
124
132
125
133
await comment . afterValidate ( context , settings , '' , result )
134
+ await Helper . flushPromises ( )
135
+
126
136
expect ( context . octokit . issues . deleteComment . mock . calls . length ) . toBe ( 1 )
127
137
expect ( context . octokit . issues . deleteComment . mock . calls [ 0 ] [ 0 ] . comment_id ) . toBe ( '2' )
128
138
} )
@@ -156,6 +166,7 @@ test('error handling includes removing old error comments and creating new error
156
166
}
157
167
158
168
await comment . handleError ( context , payload )
169
+
159
170
expect ( context . octokit . issues . deleteComment . mock . calls . length ) . toBe ( 1 )
160
171
expect ( context . octokit . issues . deleteComment . mock . calls [ 0 ] [ 0 ] . comment_id ) . toBe ( '3' )
161
172
expect ( context . octokit . issues . createComment . mock . calls [ 0 ] [ 0 ] . body ) . toBe ( payload . body )
@@ -187,6 +198,7 @@ test('remove error comments only remove comments that includes "error" ', async
187
198
const context = createMockContext ( listComments )
188
199
189
200
await comment . removeErrorComments ( context , comment )
201
+
190
202
expect ( context . octokit . issues . deleteComment . mock . calls . length ) . toBe ( 1 )
191
203
expect ( context . octokit . issues . deleteComment . mock . calls [ 0 ] [ 0 ] . comment_id ) . toBe ( '3' )
192
204
} )
@@ -224,6 +236,7 @@ test('check that leave_old_comment option works', async () => {
224
236
}
225
237
226
238
await comment . afterValidate ( context , settings , '' , result )
239
+
227
240
expect ( context . octokit . issues . deleteComment . mock . calls . length ) . toBe ( 0 )
228
241
} )
229
242
@@ -240,6 +253,7 @@ test('remove Error comment fail gracefully if payload does not exists', async ()
240
253
}
241
254
242
255
await comment . removeErrorComments ( context )
256
+
243
257
expect ( context . octokit . issues . deleteComment . mock . calls . length ) . toBe ( 0 )
244
258
} )
245
259
@@ -253,11 +267,13 @@ test('error handling includes removing old error comments and creating new error
253
267
}
254
268
255
269
await comment . afterValidate ( context , settings , '' , result )
270
+ await Helper . flushPromises ( )
271
+
256
272
expect ( context . octokit . issues . createComment . mock . calls [ 0 ] [ 0 ] . body ) . toBe ( 'creator , do something!' )
257
273
} )
258
274
259
- const createMockContext = ( listComments , eventName = undefined , event = undefined ) => {
260
- const context = Helper . mockContext ( { listComments , eventName, event } )
275
+ const createMockContext = ( comments , eventName = undefined , event = undefined ) => {
276
+ const context = Helper . mockContext ( { comments , eventName, event } )
261
277
262
278
context . octokit . issues . createComment = jest . fn ( )
263
279
context . octokit . issues . deleteComment = jest . fn ( )
0 commit comments