(i18n) install jest and add tests

We install Jest to test our i18n package.
We tests:
  - the extraction of the translations on the Desk app fo crowdin
  - the formatings of the translations from crowdin to the app
  - we check that all the translations are present in the app
We connect the tests to the CI.
This commit is contained in:
Anthony LC
2024-01-24 15:19:49 +01:00
committed by Anthony LC
parent 3d0824e023
commit 801cb98e15
9 changed files with 223 additions and 12 deletions

View File

@@ -28,7 +28,7 @@ fs.readdirSync(folderPath).map((language) => {
const pathTranslateFile = path.join(languagePath, path.sep, namefile);
if (!fs.existsSync(pathTranslateFile)) {
return;
throw new Error(`File ${pathTranslateFile} not found!`);
}
const json = JSON.parse(fs.readFileSync(pathTranslateFile, "utf8"));
@@ -43,6 +43,10 @@ fs.readdirSync(folderPath).map((language) => {
};
});
if (!Object.keys(jsonI18n).length) {
throw new Error(`No translation to deploy`);
}
// Write the file to the output
fs.writeFileSync(output, JSON.stringify(jsonI18n), "utf8");