@@ -203,13 +203,11 @@ test('Retry create comment when it fails', async () => {
203203test ( 'create (draft) PR' , async ( ) => {
204204 const createPR = jest . fn ( )
205205 let capturedCommitMessage = ''
206- const createCommit = ( { message } ) => {
207- capturedCommitMessage = message
208- return ( { data : { sha : 'abcd1234' } } )
209- }
210206 const ctx = helpers . getDefaultContext ( )
211207 ctx . octokit . pulls . create = createPR
212- ctx . octokit . git . createCommit = createCommit
208+ ctx . octokit . graphql = ( _ , { message } ) => {
209+ capturedCommitMessage = message
210+ }
213211
214212 await github . createPr ( { log : ( ) => { } } , ctx , { silent : false } , 'robvanderleek' , 'issue-1' )
215213 expect ( createPR ) . toHaveBeenCalledWith ( {
@@ -237,11 +235,10 @@ test('create (draft) PR', async () => {
237235
238236test ( 'copy Issue description into PR' , async ( ) => {
239237 const createPR = jest . fn ( )
240- const createCommit = ( ) => ( { data : { sha : 'abcd1234' } } )
241238 const ctx = helpers . getDefaultContext ( )
242239 ctx . octokit . pulls . create = createPR
243- ctx . octokit . git . createCommit = createCommit
244240 ctx . payload . issue . body = 'This is the description'
241+ ctx . octokit . graphql = jest . fn ( )
245242
246243 await github . createPr ( { log : ( ) => { } } , ctx , { copyIssueDescriptionToPR : true , silent : false } , 'robvanderleek' ,
247244 'issue-1' )
@@ -259,11 +256,10 @@ test('copy Issue description into PR', async () => {
259256
260257test ( 'Do not copy undefined Issue description into PR' , async ( ) => {
261258 const createPR = jest . fn ( )
262- const createCommit = ( ) => ( { data : { sha : 'abcd1234' } } )
263259 const ctx = helpers . getDefaultContext ( )
264260 ctx . octokit . pulls . create = createPR
265- ctx . octokit . git . createCommit = createCommit
266261 ctx . payload . issue . body = null
262+ ctx . octokit . graphql = jest . fn ( )
267263
268264 await github . createPr ( { log : ( ) => { } } , ctx , { copyIssueDescriptionToPR : true , silent : false } , 'robvanderleek' ,
269265 'issue-1' )
@@ -282,6 +278,7 @@ test('use correct source branch', async () => {
282278 const createPR = jest . fn ( )
283279 const ctx = helpers . getDefaultContext ( )
284280 ctx . octokit . pulls . create = createPR
281+ ctx . octokit . graphql = jest . fn ( )
285282 ctx . payload . issue . labels = [ { name : 'enhancement' } ]
286283 const config = { branches : [ { label : 'enhancement' , name : 'develop' } ] }
287284
@@ -301,6 +298,7 @@ test('use configured target branch', async () => {
301298 const createPR = jest . fn ( )
302299 const ctx = helpers . getDefaultContext ( )
303300 ctx . octokit . pulls . create = createPR
301+ ctx . octokit . graphql = jest . fn ( )
304302 ctx . payload . issue . labels = [ { name : 'enhancement' } ]
305303 const config = { branches : [ { label : 'enhancement' , prTarget : 'develop' } ] }
306304
@@ -320,6 +318,7 @@ test('configured source and target branch', async () => {
320318 const createPR = jest . fn ( )
321319 const ctx = helpers . getDefaultContext ( )
322320 ctx . octokit . pulls . create = createPR
321+ ctx . octokit . graphql = jest . fn ( )
323322 ctx . payload . issue . labels = [ { name : 'hotfix' } ]
324323 const config = { branches : [ { label : 'hotfix' , name : 'develop' , prTarget : 'hotfix' } ] }
325324
@@ -337,11 +336,10 @@ test('configured source and target branch', async () => {
337336
338337test ( 'copy Issue milestone into PR' , async ( ) => {
339338 const updateIssue = jest . fn ( )
340- const createCommit = ( ) => ( { data : { sha : 'abcd1234' } } )
341339 const ctx = helpers . getDefaultContext ( )
342340 ctx . octokit . pulls . create = ( ) => ( { data : { number : 123 } } )
343341 ctx . octokit . issues . update = updateIssue
344- ctx . octokit . git . createCommit = createCommit
342+ ctx . octokit . graphql = jest . fn ( )
345343 ctx . payload . issue . body = 'This is the description'
346344 ctx . payload . issue . milestone = { number : 456 }
347345
@@ -353,27 +351,31 @@ test('copy Issue milestone into PR', async () => {
353351} )
354352
355353test ( 'empty commit text' , async ( ) => {
356- const createCommit = jest . fn ( )
357354 const ctx = helpers . getDefaultContext ( )
358355 ctx . octokit . pulls . create = ( ) => ( { data : { number : 123 } } )
359- ctx . octokit . git . createCommit = createCommit
356+ let capturedCommitMessage = ''
357+ ctx . octokit . graphql = ( _ , { message } ) => {
358+ capturedCommitMessage = message
359+ }
360360 ctx . payload . issue . body = 'This is the description'
361361 ctx . payload . issue . milestone = { number : 456 }
362362
363363 await github . createPr ( { log : ( ) => { } } , ctx , { } , 'robvanderleek' , 'issue-1' )
364364
365- expect ( createCommit . mock . calls [ 0 ] [ 0 ] . message ) . toBe ( 'Create PR for #1' )
365+ expect ( capturedCommitMessage ) . toBe ( 'Create PR for #1' )
366366} )
367367
368368test ( 'empty commit with skip CI text' , async ( ) => {
369- const createCommit = jest . fn ( )
370369 const ctx = helpers . getDefaultContext ( )
371370 ctx . octokit . pulls . create = ( ) => ( { data : { number : 123 } } )
372- ctx . octokit . git . createCommit = createCommit
371+ let capturedCommitMessage = ''
372+ ctx . octokit . graphql = ( _ , { message } ) => {
373+ capturedCommitMessage = message
374+ }
373375 ctx . payload . issue . body = 'This is the description'
374376 ctx . payload . issue . milestone = { number : 456 }
375377
376378 await github . createPr ( { log : ( ) => { } } , ctx , { prSkipCI : true } , 'robvanderleek' , 'issue-1' )
377379
378- expect ( createCommit . mock . calls [ 0 ] [ 0 ] . message ) . toBe ( 'Create PR for #1\n[skip ci]' )
380+ expect ( capturedCommitMessage ) . toBe ( 'Create PR for #1\n[skip ci]' )
379381} )
0 commit comments