* tools: Move schema validation to linter Migrates the schema validation process for translation files out of the `test` step and in to a `lint` step. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> * fix: typo Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> * tools: Lint motivation object Verifies that the motivation.json objects are correct, and that the quote objects are all structured properly. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> * tools: add object value validation Adds a function that validates each translation object does not have any empty keys. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> * tools: Log missing values with property chain Modifies the value validation to log property names as chains, for easier identification of misisng key values. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> * fix(tools): Correct typo Corrects the typo in the motivation-schema.js comments Co-authored-by: Tom <20648924+moT01@users.noreply.github.com> Co-authored-by: Tom <20648924+moT01@users.noreply.github.com>
53 lines
1.2 KiB
JavaScript
53 lines
1.2 KiB
JavaScript
/* global expect */
|
|
import {
|
|
availableLangs,
|
|
i18nextCodes,
|
|
langDisplayNames,
|
|
langCodes
|
|
} from './allLangs';
|
|
|
|
const fs = require('fs');
|
|
const { setup } = require('jest-json-schema-extended');
|
|
|
|
setup();
|
|
|
|
const filesThatShouldExist = [
|
|
{
|
|
name: 'translations.json'
|
|
},
|
|
{
|
|
name: 'motivation.json'
|
|
},
|
|
{
|
|
name: 'trending.json'
|
|
}
|
|
];
|
|
|
|
const path = `${process.cwd()}/i18n/locales`;
|
|
|
|
describe('Locale tests:', () => {
|
|
availableLangs.client.forEach(lang => {
|
|
describe(`-- ${lang} --`, () => {
|
|
filesThatShouldExist.forEach(file => {
|
|
// check that each json file exists
|
|
test(`${file.name} file exists`, () => {
|
|
const exists = fs.existsSync(`${path}/${lang}/${file.name}`);
|
|
expect(exists).toBeTruthy();
|
|
});
|
|
});
|
|
|
|
test(`has a two character entry in the i18nextCodes variable`, () => {
|
|
expect(i18nextCodes[lang].length).toBe(2);
|
|
});
|
|
|
|
test(`has an entry in the langDisplayNames variable`, () => {
|
|
expect(langDisplayNames[lang].length).toBeGreaterThan(0);
|
|
});
|
|
|
|
test(`has an entry in the langCodes variable`, () => {
|
|
expect(langCodes[lang].length).toBeGreaterThan(0);
|
|
});
|
|
});
|
|
});
|
|
});
|