@@ -22,24 +22,32 @@ describe('moveRaws function', () => {
2222 beforeEach ( ( ) => {
2323 vi . resetAllMocks ( )
2424 originalPath = '/'
25- filesOnDisk = [ 'image.heic' , 'photo.heif' , 'clip.raw' , 'movie.mov' , 'document.txt' , 'photo.jpg' ]
25+ filesOnDisk = [
26+ 'image.heic' , 'photo.heif' , 'clip.raw' , 'movie.mov' ,
27+ 'document.txt' , 'photo.jpg' , 'video.mp4' , 'video.orig.mp4' ,
28+ ]
2629 errors = [ ]
2730 formatErrorMessage = vi . fn ( ( err , msg ) => `${ msg } : ${ err . message } ` )
2831 } )
2932
3033
31- test ( "should create 'raws' folder and move all configured raw files" , async ( ) => {
34+ test ( "should create 'raws' and 'videos' folder and move all configured raw and video files" , async ( ) => {
3235 vi . mocked ( fs . mkdir ) . mockResolvedValue ( undefined )
3336 vi . mocked ( fs . rename ) . mockResolvedValue ( undefined )
3437
3538 await moveRaws ( { originalPath, filesOnDisk, errors, formatErrorMessage } )
3639
3740 expect ( fs . mkdir ) . toHaveBeenCalledWith ( path . join ( originalPath , 'raws' ) , { recursive : true } )
38- expect ( fs . rename ) . toHaveBeenCalledTimes ( 4 )
41+ expect ( fs . mkdir ) . toHaveBeenCalledWith ( path . join ( originalPath , 'videos' ) , { recursive : true } )
42+ // 4 raw + 1 mp4 = 5 moves (movie.mov is raw, video.orig.mp4 should NOT be moved)
43+ expect ( fs . rename ) . toHaveBeenCalledTimes ( 5 )
3944 expect ( fs . rename ) . toHaveBeenCalledWith ( path . join ( originalPath , 'image.heic' ) , path . join ( originalPath , 'raws/image.heic' ) )
4045 expect ( fs . rename ) . toHaveBeenCalledWith ( path . join ( originalPath , 'photo.heif' ) , path . join ( originalPath , 'raws/photo.heif' ) )
4146 expect ( fs . rename ) . toHaveBeenCalledWith ( path . join ( originalPath , 'clip.raw' ) , path . join ( originalPath , 'raws/clip.raw' ) )
4247 expect ( fs . rename ) . toHaveBeenCalledWith ( path . join ( originalPath , 'movie.mov' ) , path . join ( originalPath , 'raws/movie.mov' ) )
48+ expect ( fs . rename ) . toHaveBeenCalledWith ( path . join ( originalPath , 'video.mp4' ) , path . join ( originalPath , 'videos/video.mp4' ) )
49+ // .orig.mp4 should NOT be moved
50+ expect ( fs . rename ) . not . toHaveBeenCalledWith ( path . join ( originalPath , 'video.orig.mp4' ) , expect . any ( String ) )
4351 expect ( errors ) . toHaveLength ( 0 )
4452 } )
4553
@@ -49,10 +57,14 @@ describe('moveRaws function', () => {
4957
5058 await moveRaws ( { originalPath, filesOnDisk, errors, formatErrorMessage } )
5159
52- // Only raw files should trigger errors
53- expect ( errors ) . toHaveLength ( 4 )
54- expect ( formatErrorMessage ) . toHaveBeenCalledTimes ( 4 )
60+ // 4 raw files + 1 video file should trigger errors
61+ expect ( errors ) . toHaveLength ( 5 )
62+ expect ( formatErrorMessage ) . toHaveBeenCalledTimes ( 5 )
5563 expect ( errors [ 0 ] ) . toContain ( 'Error moving raw file: image.heic' )
64+ expect ( errors [ 1 ] ) . toContain ( 'Error moving raw file: photo.heif' )
65+ expect ( errors [ 2 ] ) . toContain ( 'Error moving raw file: clip.raw' )
66+ expect ( errors [ 3 ] ) . toContain ( 'Error moving raw file: movie.mov' )
67+ expect ( errors [ 4 ] ) . toContain ( 'Error moving video file: video.mp4' )
5668 } )
5769
5870 test ( 'should not move files not in config' , async ( ) => {
0 commit comments