@@ -7,6 +7,7 @@ const testCommands = require('./data/commands.json');
77const testPrCommands = require ( './data/prCommands.json' ) ;
88const testCustomPrCommands = require ( './data/customPrCommands.json' ) ;
99const testCommitBranchCommands = require ( './data/commitBranchCommands.json' ) ;
10+ const testChildCommands = require ( './data/childCommands.json' ) ;
1011const testPayloadOpen = require ( './data/pr.opened.json' ) ;
1112const testPayloadSync = require ( './data/pr.sync.json' ) ;
1213const testPayloadClose = require ( './data/pr.closed.json' ) ;
@@ -1162,13 +1163,17 @@ describe('index', function () {
11621163 } ) ;
11631164
11641165 describe ( 'getCheckoutCommand' , ( ) => {
1165- const config = {
1166- branch : 'branchName' ,
1167- host : 'hostName' ,
1168- org : 'orgName' ,
1169- repo : 'repoName' ,
1170- sha : 'shaValue'
1171- } ;
1166+ let config ;
1167+
1168+ beforeEach ( ( ) => {
1169+ config = {
1170+ branch : 'branchName' ,
1171+ host : 'hostName' ,
1172+ org : 'orgName' ,
1173+ repo : 'repoName' ,
1174+ sha : 'shaValue'
1175+ } ;
1176+ } ) ;
11721177
11731178 it ( 'resolves checkout command without prRef' , ( ) =>
11741179 scm . getCheckoutCommand ( config ) . then ( ( command ) => {
@@ -1185,6 +1190,8 @@ describe('index', function () {
11851190 } ) ;
11861191
11871192 it ( 'resolves checkout command with custom username and email' , ( ) => {
1193+ config . prRef = 'prBranch' ;
1194+
11881195 scm = new BitbucketScm ( {
11891196 oauthClientId : 'myclientid' ,
11901197 oauthClientSecret : 'myclientsecret' ,
@@ -1200,12 +1207,26 @@ describe('index', function () {
12001207
12011208 it ( 'resolves checkout command without prRef' , ( ) => {
12021209 config . commitBranch = 'commitBranch' ;
1203- config . prRef = undefined ;
12041210
12051211 return scm . getCheckoutCommand ( config ) . then ( ( command ) => {
12061212 assert . deepEqual ( command , testCommitBranchCommands ) ;
12071213 } ) ;
12081214 } ) ;
1215+
1216+ it ( 'promises to get the checkout command for a child pipeline' , ( ) => {
1217+ config . parentConfig = {
1218+ branch : 'master' ,
1219+ host : 'github.com' ,
1220+ org : 'screwdriver-cd' ,
1221+ repo : 'parent-repo' ,
1222+ sha : '54321'
1223+ } ;
1224+
1225+ return scm . getCheckoutCommand ( config )
1226+ . then ( ( command ) => {
1227+ assert . deepEqual ( command , testChildCommands ) ;
1228+ } ) ;
1229+ } ) ;
12091230 } ) ;
12101231
12111232 describe ( 'stats' , ( ) => {
0 commit comments