@@ -3,6 +3,7 @@ const assert = require ('assert')
33const ShellCommand = require ( '../lib/ShellCommand' )
44const GitRepo = require ( '../lib/GitRepo' )
55const GitBranch = require ( '../lib/GitBranch' )
6+ const OldGit = require ( '../lib/OldGit' )
67const MrCommand = require ( '../lib/MrCommand' )
78const ParsedArgs = require ( '../lib/ParsedArgs' )
89const Push = require ( '../lib/PushCommand' )
@@ -19,7 +20,7 @@ describe('random input', () => {
1920 return `e46431c45f3c46d87c22cf63d70db2f4435bd89b refs/heads/TASK-42`
2021 case 'git branch --list TASK-43' :
2122 return ``
22- case "git config --default '' --get mr.test" :
23+ case "git config mr.test" :
2324 return ``
2425 default :
2526 throw new Error ( `Unknow command: ${ this . cmd } ` )
@@ -41,11 +42,16 @@ describe('random input', () => {
4142 return new GitBranch ( { name : 'main' , origin : 'gitlab' } )
4243 } )
4344
45+ mock . method ( OldGit . prototype , 'translate' , function ( o ) {
46+ return o
47+ } )
48+
4449 it ( 'push on empty arguments' , async ( t ) => {
4550 const parsedArgs = new ParsedArgs ( [ ] )
4651 const gitRepo = new GitRepo ( )
4752 const commands = { Push : new Push ( { gitRepo, parsedArgs} ) }
48- const todo = await new MrCommand ( { parsedArgs, gitRepo, commands} ) . todo ( )
53+ const oldGit = new OldGit ( )
54+ const todo = await new MrCommand ( { parsedArgs, gitRepo, commands, oldGit} ) . todo ( )
4955 assert . deepStrictEqual ( todo , {
5056 todo : [
5157 'git push --set-upstream gitlab TASK-42:TASK-42'
@@ -57,11 +63,12 @@ describe('random input', () => {
5763 const parsedArgs = new ParsedArgs ( [ 'TASK-42' ] )
5864 const gitRepo = new GitRepo ( )
5965 const commands = { Switch : new Switch ( { gitRepo, parsedArgs} ) }
60- const todo = await new MrCommand ( { parsedArgs, gitRepo, commands} ) . todo ( )
66+ const oldGit = new OldGit ( )
67+ const todo = await new MrCommand ( { parsedArgs, gitRepo, commands, oldGit} ) . todo ( )
6168 assert . deepStrictEqual ( todo , {
6269 todo : [
6370 'git fetch' ,
64- 'git switch --merge --guess TASK-42' ,
71+ 'git switch --guess --merge TASK-42' ,
6572 ]
6673 } )
6774 } )
@@ -70,15 +77,14 @@ describe('random input', () => {
7077 const parsedArgs = new ParsedArgs ( [ 'TASK-43' ] )
7178 const gitRepo = new GitRepo ( )
7279 const createCommand = new Create ( { gitRepo, parsedArgs} )
80+ const oldGit = new OldGit ( )
7381 const commands = { Switch : new Switch ( { gitRepo, parsedArgs, createCommand} ) }
74- const todo = await new MrCommand ( { parsedArgs, gitRepo, commands} ) . todo ( )
82+ const todo = await new MrCommand ( { parsedArgs, gitRepo, commands, oldGit } ) . todo ( )
7583 assert . deepStrictEqual ( todo , {
84+ confirmLabel : `Create new branch 'TASK-43' from 'gitlab/main' [Y/n]? ` ,
7685 todo : [
7786 'git fetch' ,
78- {
79- todo : 'git switch --guess --merge --create TASK-43 gitlab/main' ,
80- confirm : "Create new branch 'TASK-43' from 'gitlab/main' [Y/n]? " ,
81- } ,
87+ 'git switch --guess --merge --create TASK-43 gitlab/main' ,
8288 `git config branch.TASK-43.mr-target gitlab/main`
8389 ]
8490 } )
0 commit comments