@@ -859,6 +859,73 @@ user.password=Contraseña
859859 ) ;
860860 } ) ;
861861 } ) ;
862+ describe ( 'srt bucket loader' , ( ) => {
863+ it ( 'should load srt' , async ( ) => {
864+ setupFileMocks ( ) ;
865+
866+ const input = `
867+ 1
868+ 00:00:00,000 --> 00:00:01,000
869+ Hello!
870+
871+ 2
872+ 00:00:01,000 --> 00:00:02,000
873+ World!
874+ ` . trim ( ) ;
875+ const expectedOutput = { "1#00:00:00,000-00:00:01,000" : "Hello!" , "2#00:00:01,000-00:00:02,000" : "World!" } ;
876+
877+ mockFileOperations ( input ) ;
878+
879+ const srtLoader = createBucketLoader ( 'srt' , 'i18n/[locale].srt' ) ;
880+ srtLoader . setDefaultLocale ( 'en' ) ;
881+ const data = await srtLoader . pull ( 'en' ) ;
882+
883+ expect ( data ) . toEqual ( expectedOutput ) ;
884+ } ) ;
885+
886+
887+ it ( 'should save srt' , async ( ) => {
888+ setupFileMocks ( ) ;
889+
890+ const input = `
891+ 1
892+ 00:00:00,000 --> 00:00:01,000
893+ Hello!
894+
895+ 2
896+ 00:00:01,000 --> 00:00:02,000
897+ World!
898+ ` . trim ( ) ;
899+
900+ const payload = { "1#00:00:00,000-00:00:01,000" : "¡Hola!" , "2#00:00:01,000-00:00:02,000" : "Mundo!" }
901+
902+ const expectedOutput = `1
903+ 00:00:00,000 --> 00:00:01,000
904+ ¡Hola!
905+
906+ 2
907+ 00:00:01,000 --> 00:00:02,000
908+ Mundo!\n` ;
909+
910+
911+ mockFileOperations ( input ) ;
912+
913+ const srtLoader = createBucketLoader ( 'srt' , 'i18n/[locale].srt' ) ;
914+ srtLoader . setDefaultLocale ( 'en' ) ;
915+ await srtLoader . pull ( 'en' ) ;
916+
917+ await srtLoader . push ( 'es' , payload ) ;
918+
919+ expect ( fs . writeFile ) . toHaveBeenCalledWith (
920+ 'i18n/es.srt' ,
921+ expectedOutput ,
922+ { encoding : 'utf-8' , flag : 'w' } ,
923+ ) ;
924+ } ) ;
925+
926+ } ) ;
927+
928+
862929} ) ;
863930
864931// Helper functions
0 commit comments