refs #964 Add a spec to check duplicate keys between translation and missing json

This commit is contained in:
AkiraFukushima 2019-07-17 22:11:07 +09:00
parent 73f0535292
commit c3c3e0838b
3 changed files with 20 additions and 0 deletions

View File

@ -24,4 +24,22 @@ describe('i18n', () => {
})
})
})
describe('should not define duplicate keys', () => {
locales.map(locale => {
it(`${locale} translation`, () => {
const targetJson = JSON.parse(
fs.readFileSync(path.resolve(__dirname, `../../src/config/locales/${locale}/translation.json`), 'utf8')
)
const targetMissingJson = JSON.parse(
fs.readFileSync(path.resolve(__dirname, `../../src/config/locales/${locale}/translation.missing.json`), 'utf8')
)
const allKeys = keys(targetJson).concat(keys(targetMissingJson))
const duplicates: Array<string> = allKeys.filter(
(x: string, _: number, self: Array<string>) => self.indexOf(x) !== self.lastIndexOf(x)
)
expect(duplicates).toEqual([])
})
})
})
})

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1 @@
{}