@@ -1636,6 +1636,42 @@ return array(
16361636
16371637 expect ( fs . writeFile ) . toHaveBeenCalledWith ( "i18n/es.php" , expectedOutput , { encoding : "utf-8" , flag : "w" } ) ;
16381638 } ) ;
1639+
1640+ describe ( "po bucket loader" , ( ) => {
1641+ it ( "should load po file" , async ( ) => {
1642+ setupFileMocks ( ) ;
1643+
1644+ const input = `msgid "Hello"\nmsgstr "Hello"` ;
1645+ const expectedOutput = { "Hello/singular" : "Hello" } ;
1646+
1647+ mockFileOperations ( input ) ;
1648+
1649+ const jsonLoader = createBucketLoader ( "po" , "i18n/[locale].po" ) ;
1650+ jsonLoader . setDefaultLocale ( "en" ) ;
1651+ const data = await jsonLoader . pull ( "en" ) ;
1652+
1653+ expect ( data ) . toEqual ( expectedOutput ) ;
1654+ } ) ;
1655+
1656+ it ( "should save po file" , async ( ) => {
1657+ setupFileMocks ( ) ;
1658+
1659+ const input = `msgid "Hello"\nmsgstr "Hello"` ;
1660+ const expectedOutput = `msgid "Hello"\nmsgstr "Hola"` ;
1661+
1662+ mockFileOperations ( input ) ;
1663+
1664+ const jsonLoader = createBucketLoader ( "po" , "i18n/[locale].po" ) ;
1665+ jsonLoader . setDefaultLocale ( "en" ) ;
1666+ await jsonLoader . pull ( "en" ) ;
1667+
1668+ await jsonLoader . push ( "es" , {
1669+ "Hello/singular" : "Hola" ,
1670+ } ) ;
1671+
1672+ expect ( fs . writeFile ) . toHaveBeenCalledWith ( "i18n/es.po" , expectedOutput , { encoding : "utf-8" , flag : "w" } ) ;
1673+ } ) ;
1674+ } ) ;
16391675 } ) ;
16401676} ) ;
16411677
0 commit comments