@@ -140,27 +140,38 @@ describe('createRepo', () => {
140140 mockExeca . mockResolvedValue ( { stdout : '' , stderr : '' , exitCode : 0 } ) ;
141141 } ) ;
142142
143- it ( 'calls gh repo create with expected args and returns repo URL' , async ( ) => {
143+ it ( 'initializes git and calls gh repo create with expected args and returns repo URL' , async ( ) => {
144144 const url = await createRepo ( {
145145 repoName : 'my-app' ,
146146 projectPath,
147147 username,
148148 } ) ;
149149
150150 expect ( url ) . toBe ( 'https://github.com/octocat/my-app.git' ) ;
151- expect ( mockExeca ) . toHaveBeenCalledWith (
151+ expect ( mockExeca ) . toHaveBeenCalledTimes ( 4 ) ;
152+ expect ( mockExeca ) . toHaveBeenNthCalledWith ( 1 , 'git' , [ 'init' ] , {
153+ stdio : 'inherit' ,
154+ cwd : projectPath ,
155+ } ) ;
156+ expect ( mockExeca ) . toHaveBeenNthCalledWith ( 2 , 'git' , [ 'add' , '.' ] , {
157+ stdio : 'inherit' ,
158+ cwd : projectPath ,
159+ } ) ;
160+ expect ( mockExeca ) . toHaveBeenNthCalledWith ( 3 , 'git' , [ 'commit' , '-m' , 'Initial commit' ] , {
161+ stdio : 'inherit' ,
162+ cwd : projectPath ,
163+ } ) ;
164+ expect ( mockExeca ) . toHaveBeenNthCalledWith (
165+ 4 ,
152166 'gh' ,
153167 [
154168 'repo' ,
155169 'create' ,
156170 'my-app' ,
157171 '--public' ,
158- '--source' ,
159- projectPath ,
160- '--description' ,
161- '' ,
162- '--remote' ,
163- 'origin' ,
172+ `--source=${ projectPath } ` ,
173+ '--remote=origin' ,
174+ '--push' ,
164175 ] ,
165176 { stdio : 'inherit' , cwd : projectPath } ,
166177 ) ;
@@ -174,9 +185,10 @@ describe('createRepo', () => {
174185 description : 'My cool project' ,
175186 } ) ;
176187
177- expect ( mockExeca ) . toHaveBeenCalledWith (
188+ expect ( mockExeca ) . toHaveBeenNthCalledWith (
189+ 4 ,
178190 'gh' ,
179- expect . arrayContaining ( [ '--description' , ' My cool project'] ) ,
191+ expect . arrayContaining ( [ '--description= My cool project' ] ) ,
180192 expect . any ( Object ) ,
181193 ) ;
182194 } ) ;
0 commit comments