@@ -406,6 +406,73 @@ Otro párrafo con texto en **negrita** y en *cursiva*.
406406 } ) ;
407407 } ) ;
408408
409+ describe ( 'po bucket loader' , ( ) => {
410+ it ( 'should load and handle various po data' , async ( ) => {
411+ setupFileMocks ( ) ;
412+
413+ const input = `
414+ # This is a comment
415+ msgid "greeting"
416+ msgstr "Hello, {name}!"
417+
418+ msgid "farewell"
419+ msgstr "Goodbye, {name}!"
420+
421+ # Another comment
422+ msgid "empty"
423+ msgstr ""
424+ ` . trim ( ) ;
425+ const expectedOutput = {
426+ greeting : 'Hello, {name}!' ,
427+ farewell : 'Goodbye, {name}!' ,
428+ empty : ''
429+ } ;
430+
431+ mockFileOperations ( input ) ;
432+
433+ const poLoader = createBucketLoader ( 'po' , 'i18n/[locale].po' ) ;
434+ poLoader . setDefaultLocale ( 'en' ) ;
435+ const data = await poLoader . pull ( 'en' ) ;
436+
437+ expect ( data ) . toEqual ( expectedOutput ) ;
438+ } ) ;
439+
440+ it ( 'should save po data with variable patterns and comments' , async ( ) => {
441+ setupFileMocks ( ) ;
442+
443+ const input = `
444+ # This is a comment
445+ msgid "greeting"
446+ msgstr "Hello, {name}!"
447+ ` . trim ( ) ;
448+ const payload = {
449+ greeting : '¡Hola, {name}!' ,
450+ farewell : '¡Adiós, {name}!'
451+ } ;
452+ const expectedOutput = `
453+ msgid "greeting"
454+ msgstr "¡Hola, {name}!"
455+
456+ msgid "farewell"
457+ msgstr "¡Adiós, {name}!"
458+ ` . trim ( ) + '\n' ;
459+
460+ mockFileOperations ( input ) ;
461+
462+ const poLoader = createBucketLoader ( 'po' , 'i18n/[locale].po' ) ;
463+ poLoader . setDefaultLocale ( 'es' ) ;
464+ await poLoader . pull ( 'es' ) ;
465+
466+ await poLoader . push ( 'es' , payload ) ;
467+
468+ expect ( fs . writeFile ) . toHaveBeenCalledWith (
469+ 'i18n/es.po' ,
470+ expectedOutput ,
471+ { encoding : 'utf-8' , flag : 'w' } ,
472+ ) ;
473+ } ) ;
474+ } ) ;
475+
409476 describe ( 'properties bucket loader' , ( ) => {
410477 it ( 'should load properties data' , async ( ) => {
411478 setupFileMocks ( ) ;
0 commit comments