11import * as core from '@actions/core'
22import * as exec from '@actions/exec'
3- import { describe , jest , beforeEach , afterAll , it , expect } from '@jest/globals '
3+ import { describe , vi , beforeEach , it , expect } from 'vitest '
44import * as cwd from '../src/utils/cwd'
55import {
66 addFileChanges ,
@@ -11,12 +11,12 @@ import {
1111
1212describe ( 'Git CLI' , ( ) => {
1313 beforeEach ( ( ) => {
14- jest . restoreAllMocks ( )
14+ vi . restoreAllMocks ( )
1515 } )
1616
1717 describe ( 'git checkout' , ( ) => {
1818 it ( 'should create new branch' , async ( ) => {
19- const execMock = jest . spyOn ( exec , 'exec' ) . mockResolvedValue ( 0 )
19+ const execMock = vi . spyOn ( exec , 'exec' ) . mockResolvedValue ( 0 )
2020
2121 await switchBranch ( 'new-branch' )
2222 expect ( execMock ) . toHaveBeenCalledWith (
@@ -29,7 +29,7 @@ describe('Git CLI', () => {
2929 } )
3030
3131 it ( 'should log debug' , async ( ) => {
32- const execMock = jest
32+ const execMock = vi
3333 . spyOn ( exec , 'exec' )
3434 . mockImplementationOnce ( async ( cmd , args , options ) => {
3535 const io = options ?. listeners ?. stdline
@@ -40,15 +40,15 @@ describe('Git CLI', () => {
4040 return 0
4141 } )
4242
43- const debugMock = jest . spyOn ( core , 'debug' ) . mockReturnValue ( )
43+ const debugMock = vi . spyOn ( core , 'debug' ) . mockReturnValue ( )
4444
4545 await switchBranch ( 'new-branch' )
4646 expect ( execMock ) . toHaveBeenCalled ( )
4747 expect ( debugMock ) . toHaveBeenCalledWith ( 'git checkout debug log message' )
4848 } )
4949
5050 it ( 'should log warning' , async ( ) => {
51- const execMock = jest
51+ const execMock = vi
5252 . spyOn ( exec , 'exec' )
5353 . mockImplementationOnce ( async ( cmd , args , options ) => {
5454 const io = options ?. listeners ?. errline
@@ -59,7 +59,7 @@ describe('Git CLI', () => {
5959 return 0
6060 } )
6161
62- const warningMock = jest . spyOn ( core , 'warning' ) . mockReturnValue ( )
62+ const warningMock = vi . spyOn ( core , 'warning' ) . mockReturnValue ( )
6363
6464 await switchBranch ( 'new-branch' )
6565 expect ( execMock ) . toHaveBeenCalled ( )
@@ -69,7 +69,7 @@ describe('Git CLI', () => {
6969 } )
7070
7171 it ( 'should log error' , async ( ) => {
72- const execMock = jest
72+ const execMock = vi
7373 . spyOn ( exec , 'exec' )
7474 . mockImplementationOnce ( async ( cmd , args , options ) => {
7575 const io = options ?. listeners ?. errline
@@ -80,7 +80,7 @@ describe('Git CLI', () => {
8080 return 0
8181 } )
8282
83- const errorMock = jest . spyOn ( core , 'error' ) . mockReturnValue ( )
83+ const errorMock = vi . spyOn ( core , 'error' ) . mockReturnValue ( )
8484
8585 await switchBranch ( 'new-branch' )
8686 expect ( execMock ) . toHaveBeenCalled ( )
@@ -90,11 +90,11 @@ describe('Git CLI', () => {
9090
9191 describe ( 'git push' , ( ) => {
9292 beforeEach ( ( ) => {
93- jest . spyOn ( core , 'getBooleanInput' ) . mockReturnValue ( false )
93+ vi . spyOn ( core , 'getBooleanInput' ) . mockReturnValue ( false )
9494 } )
9595
9696 it ( 'should push new branch' , async ( ) => {
97- const execMock = jest . spyOn ( exec , 'exec' ) . mockResolvedValue ( 0 )
97+ const execMock = vi . spyOn ( exec , 'exec' ) . mockResolvedValue ( 0 )
9898
9999 await pushCurrentBranch ( )
100100 expect ( execMock ) . toHaveBeenCalledWith (
@@ -107,8 +107,8 @@ describe('Git CLI', () => {
107107 } )
108108
109109 it ( 'should force push new branch' , async ( ) => {
110- const execMock = jest . spyOn ( exec , 'exec' ) . mockResolvedValue ( 0 )
111- const getInput = jest . spyOn ( core , 'getBooleanInput' ) . mockReturnValue ( true )
110+ const execMock = vi . spyOn ( exec , 'exec' ) . mockResolvedValue ( 0 )
111+ const getInput = vi . spyOn ( core , 'getBooleanInput' ) . mockReturnValue ( true )
112112
113113 await pushCurrentBranch ( )
114114 expect ( execMock ) . toHaveBeenCalled ( )
@@ -123,7 +123,7 @@ describe('Git CLI', () => {
123123 } )
124124
125125 it ( 'should log debug' , async ( ) => {
126- const execMock = jest
126+ const execMock = vi
127127 . spyOn ( exec , 'exec' )
128128 . mockImplementationOnce ( async ( cmd , args , options ) => {
129129 const io = options ?. listeners ?. stdline
@@ -134,15 +134,15 @@ describe('Git CLI', () => {
134134 return 0
135135 } )
136136
137- const debugMock = jest . spyOn ( core , 'debug' ) . mockReturnValue ( )
137+ const debugMock = vi . spyOn ( core , 'debug' ) . mockReturnValue ( )
138138
139139 await pushCurrentBranch ( )
140140 expect ( execMock ) . toHaveBeenCalled ( )
141141 expect ( debugMock ) . toHaveBeenCalledWith ( 'git push debug log message' )
142142 } )
143143
144144 it ( 'should log warning' , async ( ) => {
145- const execMock = jest
145+ const execMock = vi
146146 . spyOn ( exec , 'exec' )
147147 . mockImplementationOnce ( async ( cmd , args , options ) => {
148148 const io = options ?. listeners ?. errline
@@ -153,15 +153,15 @@ describe('Git CLI', () => {
153153 return 0
154154 } )
155155
156- const warningMock = jest . spyOn ( core , 'warning' ) . mockReturnValue ( )
156+ const warningMock = vi . spyOn ( core , 'warning' ) . mockReturnValue ( )
157157
158158 await pushCurrentBranch ( )
159159 expect ( execMock ) . toHaveBeenCalled ( )
160160 expect ( warningMock ) . toHaveBeenCalledWith ( 'git push warning log message' )
161161 } )
162162
163163 it ( 'should log error' , async ( ) => {
164- const execMock = jest
164+ const execMock = vi
165165 . spyOn ( exec , 'exec' )
166166 . mockImplementationOnce ( async ( cmd , args , options ) => {
167167 const io = options ?. listeners ?. errline
@@ -172,7 +172,7 @@ describe('Git CLI', () => {
172172 return 0
173173 } )
174174
175- const errorMock = jest . spyOn ( core , 'error' ) . mockReturnValue ( )
175+ const errorMock = vi . spyOn ( core , 'error' ) . mockReturnValue ( )
176176
177177 await pushCurrentBranch ( )
178178 expect ( execMock ) . toHaveBeenCalled ( )
@@ -182,11 +182,11 @@ describe('Git CLI', () => {
182182
183183 describe ( 'git add' , ( ) => {
184184 beforeEach ( ( ) => {
185- jest . spyOn ( cwd , 'getWorkspace' ) . mockReturnValue ( '/test-workspace' )
185+ vi . spyOn ( cwd , 'getWorkspace' ) . mockReturnValue ( '/test-workspace' )
186186 } )
187187
188188 it ( 'should ensure file paths are within curent working directory' , async ( ) => {
189- const execMock = jest . spyOn ( exec , 'exec' ) . mockResolvedValue ( 0 )
189+ const execMock = vi . spyOn ( exec , 'exec' ) . mockResolvedValue ( 0 )
190190
191191 await addFileChanges ( [ '*.ts' , '~/.bashrc' ] )
192192 expect ( execMock ) . toHaveBeenCalledWith (
@@ -199,7 +199,7 @@ describe('Git CLI', () => {
199199 } )
200200
201201 it ( 'should log debug' , async ( ) => {
202- const execMock = jest
202+ const execMock = vi
203203 . spyOn ( exec , 'exec' )
204204 . mockImplementationOnce ( async ( cmd , args , options ) => {
205205 const io = options ?. listeners ?. stdline
@@ -210,15 +210,15 @@ describe('Git CLI', () => {
210210 return 0
211211 } )
212212
213- const debugMock = jest . spyOn ( core , 'debug' ) . mockReturnValue ( )
213+ const debugMock = vi . spyOn ( core , 'debug' ) . mockReturnValue ( )
214214
215215 await addFileChanges ( [ '*.ts' ] )
216216 expect ( execMock ) . toHaveBeenCalled ( )
217217 expect ( debugMock ) . toHaveBeenCalledWith ( 'git add debug log message' )
218218 } )
219219
220220 it ( 'should log warning' , async ( ) => {
221- const execMock = jest
221+ const execMock = vi
222222 . spyOn ( exec , 'exec' )
223223 . mockImplementationOnce ( async ( cmd , args , options ) => {
224224 const io = options ?. listeners ?. errline
@@ -229,15 +229,15 @@ describe('Git CLI', () => {
229229 return 0
230230 } )
231231
232- const warningMock = jest . spyOn ( core , 'warning' ) . mockReturnValue ( )
232+ const warningMock = vi . spyOn ( core , 'warning' ) . mockReturnValue ( )
233233
234234 await addFileChanges ( [ '*.ts' ] )
235235 expect ( execMock ) . toHaveBeenCalled ( )
236236 expect ( warningMock ) . toHaveBeenCalledWith ( 'git add warning log message' )
237237 } )
238238
239239 it ( 'should log error' , async ( ) => {
240- const execMock = jest
240+ const execMock = vi
241241 . spyOn ( exec , 'exec' )
242242 . mockImplementationOnce ( async ( cmd , args , options ) => {
243243 const io = options ?. listeners ?. errline
@@ -248,7 +248,7 @@ describe('Git CLI', () => {
248248 return 0
249249 } )
250250
251- const errorMock = jest . spyOn ( core , 'error' ) . mockReturnValue ( )
251+ const errorMock = vi . spyOn ( core , 'error' ) . mockReturnValue ( )
252252
253253 await addFileChanges ( [ '*.ts' ] )
254254 expect ( execMock ) . toHaveBeenCalled ( )
@@ -271,7 +271,7 @@ describe('Git CLI', () => {
271271 ]
272272
273273 it ( 'should parse ouput into file changes' , async ( ) => {
274- const execMock = jest
274+ const execMock = vi
275275 . spyOn ( exec , 'exec' )
276276 . mockImplementationOnce ( async ( cmd , args , options ) => {
277277 const io = options ?. listeners ?. stdline
@@ -321,7 +321,7 @@ describe('Git CLI', () => {
321321 } )
322322
323323 it ( 'should log warning' , async ( ) => {
324- const execMock = jest
324+ const execMock = vi
325325 . spyOn ( exec , 'exec' )
326326 . mockImplementationOnce ( async ( cmd , args , options ) => {
327327 const io = options ?. listeners ?. errline
@@ -332,15 +332,15 @@ describe('Git CLI', () => {
332332 return 0
333333 } )
334334
335- const warningMock = jest . spyOn ( core , 'warning' ) . mockReturnValue ( )
335+ const warningMock = vi . spyOn ( core , 'warning' ) . mockReturnValue ( )
336336
337337 await getFileChanges ( )
338338 expect ( execMock ) . toHaveBeenCalled ( )
339339 expect ( warningMock ) . toHaveBeenCalledWith ( 'git status warning log message' )
340340 } )
341341
342342 it ( 'should log error' , async ( ) => {
343- const execMock = jest
343+ const execMock = vi
344344 . spyOn ( exec , 'exec' )
345345 . mockImplementationOnce ( async ( cmd , args , options ) => {
346346 const io = options ?. listeners ?. errline
@@ -351,7 +351,7 @@ describe('Git CLI', () => {
351351 return 0
352352 } )
353353
354- const errorMock = jest . spyOn ( core , 'error' ) . mockReturnValue ( )
354+ const errorMock = vi . spyOn ( core , 'error' ) . mockReturnValue ( )
355355
356356 await getFileChanges ( )
357357 expect ( execMock ) . toHaveBeenCalled ( )
0 commit comments