@@ -291,13 +291,22 @@ describe('Jenkins', () => {
291291 ]
292292 } ) ;
293293
294- it ( 'should return false if already started ' , async ( ) => {
294+ it ( 'should return false if inferred commit already has CI ' , async ( ) => {
295295 const cli = new TestCLI ( ) ;
296+ sinon . replace ( PRData . prototype , 'getReviews' , sinon . fake . resolves ( ) ) ;
297+ sinon . replace ( PRData . prototype , 'getCommits' , sinon . fake . resolves ( ) ) ;
298+ sinon . replace ( PRChecker . prototype , 'getApprovedTipOfHead' ,
299+ sinon . fake . returns ( 'deadbeef' ) ) ;
296300 sinon . replace ( PRBuild . prototype , 'getBuildData' ,
297301 sinon . fake . resolves ( mockJenkinsResponse ( getParameters ( 'deadbeef' ) ) ) ) ;
298302
299- const jobRunner = new RunPRJob ( cli , { } , owner , repo , prid , 'deadbeef' , true ) ;
303+ const request = {
304+ fetch : sinon . stub ( ) . resolves ( { status : 201 } ) ,
305+ json : sinon . stub ( ) . withArgs ( CI_CRUMB_URL ) . resolves ( { crumb } )
306+ } ;
307+ const jobRunner = new RunPRJob ( cli , request , owner , repo , prid , undefined , true ) ;
300308 assert . strictEqual ( await jobRunner . start ( ) , false ) ;
309+ assert . strictEqual ( request . fetch . callCount , 0 ) ;
301310 } ) ;
302311 it ( 'should return true when last CI is on a different commit' , async ( ) => {
303312 const cli = new TestCLI ( ) ;
0 commit comments