1
0
Fork 0

fix: Updated shared design test for i18n structure

This commit is contained in:
Joost De Cock 2023-09-13 14:57:50 +02:00
parent b7b543fda0
commit e6b80ff0dd
2 changed files with 21 additions and 12 deletions

View file

@ -99,7 +99,7 @@ export const testPatternConfig = (Pattern) => {
const draft = new Pattern({
measurements: requested,
}).draft()
console.log(draft.setStores[0].logs)
const missWarnings = draft.setStores[0].logs.warn.filter((w, i, a) => {
return w.match(/tried to access `measurements/) && a.indexOf(w) === i
})

View file

@ -61,6 +61,8 @@ export const testPatternI18n = (Pattern, i18n) => {
expect(typeof i18n.en.o[key].d).to.equal('string')
expect(i18n.en.o[key].d.length).to.be.above(1)
})
if (key.split('.').length === 1) {
// Regular option
if (key.slice(-3) === 'Yes') {
it(` - The Yes translation of boolean option o.${key} should have a corresponding No translation`, () => {
expect(typeof i18n.en.o[key.slice(0, -3) + 'No'].t).to.equal('string')
@ -74,6 +76,13 @@ export const testPatternI18n = (Pattern, i18n) => {
expect(options.includes(key)).to.equal(true)
})
}
} else if (key.split('.').length === 2) {
// Entry of a list option
const [option, entry] = key.split('.')
it(` - The translation of o.${option} list option should have a transaltion for the ${entry} entry`, () => {
expect(Pattern.patternConfig.options[option].list.includes(entry)).to.equal(true)
})
}
}
for (const option of options.filter(
(o) => typeof Pattern.patternConfig.options[o] === 'object'