@@ -233,51 +233,45 @@ describe('Add Command', () => {
233233 } )
234234
235235 it ( 'should reject when file does not exist' , async ( ) => {
236- const mockExit = vi . spyOn ( process , 'exit' ) . mockImplementation ( ( ) => {
237- throw new Error ( 'process.exit called' )
238- } )
236+ const mockExit = vi . spyOn ( process , 'exit' )
239237
240238 await expect (
241239 runAdd ( {
242240 filePath : '/non/existent/file.txt' ,
243241 privateKey : 'test-key' ,
244242 } )
245- ) . rejects . toThrow ( 'process.exit called ' )
243+ ) . rejects . toThrow ( 'Path not found ' )
246244
247- expect ( mockExit ) . toHaveBeenCalledWith ( 1 )
245+ expect ( mockExit ) . not . toHaveBeenCalled ( )
248246 mockExit . mockRestore ( )
249247 } )
250248
251249 it ( 'should reject when private key is missing' , async ( ) => {
252- const mockExit = vi . spyOn ( process , 'exit' ) . mockImplementation ( ( ) => {
253- throw new Error ( 'process.exit called' )
254- } )
250+ const mockExit = vi . spyOn ( process , 'exit' )
255251
256252 await expect (
257253 runAdd ( {
258254 filePath : testFile ,
259255 // No private key
260256 } )
261- ) . rejects . toThrow ( 'process.exit called' )
257+ ) . rejects . toThrow ( )
262258
263- expect ( mockExit ) . toHaveBeenCalledWith ( 1 )
259+ expect ( mockExit ) . not . toHaveBeenCalled ( )
264260 mockExit . mockRestore ( )
265261 } )
266262
267263 it ( 'should reject --bare flag with directories' , async ( ) => {
268- const mockExit = vi . spyOn ( process , 'exit' ) . mockImplementation ( ( ) => {
269- throw new Error ( 'process.exit called' )
270- } )
264+ const mockExit = vi . spyOn ( process , 'exit' )
271265
272266 await expect (
273267 runAdd ( {
274268 filePath : testDir , // Directory
275269 privateKey : 'test-key' ,
276270 bare : true , // --bare flag should not work with directories
277271 } )
278- ) . rejects . toThrow ( 'process.exit called ' )
272+ ) . rejects . toThrow ( '--bare flag is not supported for directories ' )
279273
280- expect ( mockExit ) . toHaveBeenCalledWith ( 1 )
274+ expect ( mockExit ) . not . toHaveBeenCalled ( )
281275 mockExit . mockRestore ( )
282276 } )
283277 } )
0 commit comments