jest . mock ( "./run" ) ; import nock from "nock" ; import { Probot , ProbotOctokit } from "probot" ; import toggle from "./toggle" ; import events from "./fixtures" ; let robot ; beforeEach ( ( ) => { robot = new Probot ( { githubToken : "test" , Octokit : ProbotOctokit . defaults ( { retry : { enabled : false } , throttle : { enabled : false } , } ) , } ) ; robot . load ( ( app ) => { app . on ( "pull_request.opened" , toggle ) ; app . on ( "pull_request.edited" , toggle ) ; } ) ; nock . disableNetConnect ( ) ; } ) ; afterAll ( ( ) => { nock . cleanAll ( ) ; } ) ; test ( "add the label if there are some dependencies" , async ( ) => { nock ( "https://api.github.com" ) . post ( "/repos/user/test/issues/1/labels" , ( body ) => { expect ( body ) . toEqual ( [ "dependent" ] ) ; return true ; } ) . reply ( 200 , { } ) ; await robot . receive ( events . pull_request_edited ) ; } ) ; test ( "remove the label if there are no dependencies" , async ( ) => { nock ( "https://api.github.com" ) . post ( "/repos/user/test/issues/1/labels" , ( body ) => { expect ( body ) . toEqual ( [ ] ) ; return true ; } ) . reply ( 200 , { } ) ; await robot . receive ( events . pull_request_opened ) ; } ) ;