2020-07-01 16:20:18 +00:00
|
|
|
import { sync as glob } from 'glob';
|
2016-09-01 02:25:08 +00:00
|
|
|
|
|
|
|
|
describe('Locales files', () => {
|
2016-09-13 02:04:05 +00:00
|
|
|
it('do not contain duplicates of any keys', () => {
|
2019-10-08 18:45:38 +00:00
|
|
|
const translationFiles = glob('./website/common/locales/en/*.json');
|
2016-09-01 02:25:08 +00:00
|
|
|
|
|
|
|
|
if (translationFiles.length === 0) {
|
2016-09-16 15:18:07 +00:00
|
|
|
throw new Error('Could not find any files in ./website/common/locales/en/*.json');
|
2016-09-01 02:25:08 +00:00
|
|
|
}
|
|
|
|
|
|
2019-10-08 18:45:38 +00:00
|
|
|
const keys = {};
|
2016-09-01 02:25:08 +00:00
|
|
|
|
2019-10-08 18:45:38 +00:00
|
|
|
translationFiles.forEach(file => {
|
|
|
|
|
const json = require(`../.${file}`); // eslint-disable-line global-require, import/no-dynamic-require
|
2016-09-01 02:25:08 +00:00
|
|
|
|
2019-10-08 18:45:38 +00:00
|
|
|
Object.keys(json).forEach(key => {
|
2016-09-01 02:25:08 +00:00
|
|
|
if (keys[key]) {
|
|
|
|
|
throw new Error(`${key} in ${file} already exists in ${keys[key]}.`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
keys[key] = file;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|