@@ -33,6 +33,8 @@ test.each([
3333 } ]
3434
3535 await comment . afterValidate ( context , settings , '' , schedulerResult )
36+ await Helper . flushPromises ( )
37+
3638 expect ( context . octokit . issues . createComment . mock . calls . length ) . toBe ( 1 )
3739} )
3840
@@ -49,6 +51,8 @@ test('check that comment created when afterValidate is called with proper parame
4951 }
5052
5153 await comment . afterValidate ( context , settings , '' , result )
54+ await Helper . flushPromises ( )
55+
5256 expect ( context . octokit . issues . createComment . mock . calls . length ) . toBe ( 1 )
5357 expect ( context . octokit . issues . createComment . mock . calls [ 0 ] [ 0 ] . body ) . toBe ( 'Your run has returned the following status: pass' )
5458} )
@@ -64,6 +68,8 @@ test('that comment is created three times when result contain three issues found
6468 }
6569 } ]
6670 await comment . afterValidate ( context , settings , '' , schedulerResult )
71+ await Helper . flushPromises ( )
72+
6773 expect ( context . octokit . issues . createComment . mock . calls . length ) . toBe ( 3 )
6874} )
6975
@@ -93,6 +99,8 @@ test('check that old comments from Mergeable are deleted if they exists', async
9399 }
94100
95101 await comment . afterValidate ( context , settings , '' , result )
102+ await Helper . flushPromises ( )
103+
96104 expect ( context . octokit . issues . deleteComment . mock . calls . length ) . toBe ( 1 )
97105 expect ( context . octokit . issues . deleteComment . mock . calls [ 0 ] [ 0 ] . comment_id ) . toBe ( '2' )
98106} )
@@ -123,6 +131,8 @@ test('check that old comments checks toLowerCase of the Bot name', async () => {
123131 }
124132
125133 await comment . afterValidate ( context , settings , '' , result )
134+ await Helper . flushPromises ( )
135+
126136 expect ( context . octokit . issues . deleteComment . mock . calls . length ) . toBe ( 1 )
127137 expect ( context . octokit . issues . deleteComment . mock . calls [ 0 ] [ 0 ] . comment_id ) . toBe ( '2' )
128138} )
@@ -156,6 +166,7 @@ test('error handling includes removing old error comments and creating new error
156166 }
157167
158168 await comment . handleError ( context , payload )
169+
159170 expect ( context . octokit . issues . deleteComment . mock . calls . length ) . toBe ( 1 )
160171 expect ( context . octokit . issues . deleteComment . mock . calls [ 0 ] [ 0 ] . comment_id ) . toBe ( '3' )
161172 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
187198 const context = createMockContext ( listComments )
188199
189200 await comment . removeErrorComments ( context , comment )
201+
190202 expect ( context . octokit . issues . deleteComment . mock . calls . length ) . toBe ( 1 )
191203 expect ( context . octokit . issues . deleteComment . mock . calls [ 0 ] [ 0 ] . comment_id ) . toBe ( '3' )
192204} )
@@ -224,6 +236,7 @@ test('check that leave_old_comment option works', async () => {
224236 }
225237
226238 await comment . afterValidate ( context , settings , '' , result )
239+
227240 expect ( context . octokit . issues . deleteComment . mock . calls . length ) . toBe ( 0 )
228241} )
229242
@@ -240,6 +253,7 @@ test('remove Error comment fail gracefully if payload does not exists', async ()
240253 }
241254
242255 await comment . removeErrorComments ( context )
256+
243257 expect ( context . octokit . issues . deleteComment . mock . calls . length ) . toBe ( 0 )
244258} )
245259
@@ -253,11 +267,13 @@ test('error handling includes removing old error comments and creating new error
253267 }
254268
255269 await comment . afterValidate ( context , settings , '' , result )
270+ await Helper . flushPromises ( )
271+
256272 expect ( context . octokit . issues . createComment . mock . calls [ 0 ] [ 0 ] . body ) . toBe ( 'creator , do something!' )
257273} )
258274
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 } )
261277
262278 context . octokit . issues . createComment = jest . fn ( )
263279 context . octokit . issues . deleteComment = jest . fn ( )
0 commit comments