@@ -85,9 +85,10 @@ describe("outputMergedBranches", () => {
8585 expect ( infoSpy ) . toHaveBeenNthCalledWith ( 2 , branchOutput . join ( "\n" ) ) ;
8686
8787 const localDelete = `git branch --delete ${ branches . join ( " " ) } ` ;
88- expect ( infoSpy ) . toHaveBeenNthCalledWith ( 3 , "\nRun the following to delete branches, or use the --delete option to delete them automatically:" ) ;
89- expect ( infoSpy ) . toHaveBeenNthCalledWith ( 4 , `locally:\n ${ localDelete } ` ) ;
90- expect ( infoSpy ) . toHaveBeenCalledTimes ( 4 ) ;
88+ expect ( infoSpy ) . toHaveBeenNthCalledWith ( 3 , "\nUse --delete to delete 2 branches automatically." ) ;
89+ expect ( infoSpy ) . toHaveBeenNthCalledWith ( 4 , "\nDelete locally:" ) ;
90+ expect ( infoSpy ) . toHaveBeenNthCalledWith ( 5 , ` ${ localDelete } ` ) ;
91+ expect ( infoSpy ) . toHaveBeenCalledTimes ( 5 ) ;
9192 expect ( warnSpy ) . not . toHaveBeenCalled ( ) ;
9293 } ) ;
9394
@@ -105,10 +106,12 @@ describe("outputMergedBranches", () => {
105106
106107 const localDelete = `git branch --delete ${ branches . join ( " " ) } ` ;
107108 const remoteDelete = `git push origin --delete ${ branches . join ( " " ) } ` ;
108- expect ( infoSpy ) . toHaveBeenNthCalledWith ( 3 , "\nRun the following to delete branches, or use the --delete option to delete them automatically:" ) ;
109- expect ( infoSpy ) . toHaveBeenNthCalledWith ( 4 , `locally:\n ${ localDelete } ` ) ;
110- expect ( infoSpy ) . toHaveBeenNthCalledWith ( 5 , `remotely:\n ${ remoteDelete } ` ) ;
111- expect ( infoSpy ) . toHaveBeenCalledTimes ( 5 ) ;
109+ expect ( infoSpy ) . toHaveBeenNthCalledWith ( 3 , "\nUse --delete to delete 2 branches automatically." ) ;
110+ expect ( infoSpy ) . toHaveBeenNthCalledWith ( 4 , "\nDelete locally:" ) ;
111+ expect ( infoSpy ) . toHaveBeenNthCalledWith ( 5 , ` ${ localDelete } ` ) ;
112+ expect ( infoSpy ) . toHaveBeenNthCalledWith ( 6 , "\nDelete remotely:" ) ;
113+ expect ( infoSpy ) . toHaveBeenNthCalledWith ( 7 , ` ${ remoteDelete } ` ) ;
114+ expect ( infoSpy ) . toHaveBeenCalledTimes ( 7 ) ;
112115 expect ( warnSpy ) . not . toHaveBeenCalled ( ) ;
113116
114117 fetchRemoteMock . mockRestore ( ) ;
@@ -122,9 +125,10 @@ describe("outputMergedBranches", () => {
122125 expect ( infoSpy ) . toHaveBeenNthCalledWith ( 2 , "feat/TOKEN-800_new-feature <https://test-instance.org/browse/TOKEN-800>" ) ;
123126
124127 const localDelete = `git branch --delete ${ branches . join ( " " ) } ` ;
125- expect ( infoSpy ) . toHaveBeenNthCalledWith ( 3 , "\nRun the following to delete branches, or use the --delete option to delete them automatically:" ) ;
126- expect ( infoSpy ) . toHaveBeenNthCalledWith ( 4 , `locally:\n ${ localDelete } ` ) ;
127- expect ( infoSpy ) . toHaveBeenCalledTimes ( 4 ) ;
128+ expect ( infoSpy ) . toHaveBeenNthCalledWith ( 3 , "\nUse --delete to delete 1 branch automatically." ) ;
129+ expect ( infoSpy ) . toHaveBeenNthCalledWith ( 4 , "\nDelete locally:" ) ;
130+ expect ( infoSpy ) . toHaveBeenNthCalledWith ( 5 , ` ${ localDelete } ` ) ;
131+ expect ( infoSpy ) . toHaveBeenCalledTimes ( 5 ) ;
128132 expect ( warnSpy ) . not . toHaveBeenCalled ( ) ;
129133 } ) ;
130134
@@ -140,28 +144,23 @@ describe("outputMergedBranches", () => {
140144 const config = { ...DEFAULT_CONFIG , issueUrlFormat : "invalid-url" } ;
141145
142146 outputMergedBranches ( branches , "master" , config ) ;
143- expect ( infoSpy ) . toHaveBeenCalledTimes ( 4 ) ;
147+ expect ( infoSpy ) . toHaveBeenCalledTimes ( 5 ) ;
144148 expect ( warnSpy ) . toHaveBeenCalledWith ( "'invalid-url' is not a valid URL. Skipped formatting." ) ;
145149 expect ( warnSpy ) . toHaveBeenCalledTimes ( 1 ) ;
146150 } ) ;
147151
148152 it ( "should delete branches when --delete option is passed" , ( ) => {
149- const deleteLocalMock = vi . spyOn ( repoMethods , "deleteLocalBranches" ) . mockImplementation ( ( ) => { } ) ;
150- const deleteRemoteMock = vi . spyOn ( repoMethods , "deleteRemoteBranches" ) . mockImplementation ( ( ) => { } ) ;
153+ const deleteMock = vi . spyOn ( repoMethods , "deleteBranches" ) . mockImplementation ( ( ) => { } ) ;
151154
152155 const branches = [ "feat/TOKEN-800_new-feature" , "fix/TOKEN-123_some-fix" ] ;
153156 const fetchRemoteMock = vi . spyOn ( repoMethods , "fetchRemoteBranches" ) . mockReturnValue ( branches ) ;
154157
155158 outputMergedBranches ( branches , "master" , DEFAULT_CONFIG , { deleteBranches : true } ) ;
156159
157- expect ( deleteLocalMock ) . toHaveBeenCalledWith ( branches ) ;
158- expect ( deleteRemoteMock ) . toHaveBeenCalledWith ( branches ) ;
159- expect ( infoSpy ) . toHaveBeenCalledWith ( "\nDeleting branches locally..." ) ;
160- expect ( infoSpy ) . toHaveBeenCalledWith ( "\nDeleting branches remotely..." ) ;
160+ expect ( deleteMock ) . toHaveBeenCalledWith ( branches , branches ) ;
161161 expect ( infoSpy ) . toHaveBeenCalledWith ( "Branches deleted successfully." ) ;
162162
163- deleteLocalMock . mockRestore ( ) ;
164- deleteRemoteMock . mockRestore ( ) ;
163+ deleteMock . mockRestore ( ) ;
165164 fetchRemoteMock . mockRestore ( ) ;
166165 } ) ;
167166} ) ;
0 commit comments