mon-entreprise/site/test/unit-translations.test.js

31 lines
838 B
JavaScript
Raw Normal View History

import rawRules from 'modele-social'
2022-11-03 16:32:04 +00:00
import { parsePublicodes } from 'publicodes'
import { describe, expect, it } from 'vitest'
import unitsTranslations from '../source/locales/units.yaml'
describe('Tests units', function () {
it('use unit that exists in publicodes', function () {
2022-02-10 11:07:19 +00:00
const { parsedRules } = parsePublicodes(rawRules)
const units = [
...new Set(
Object.keys(parsedRules).reduce(
(prev, name) => [
...prev,
...(parsedRules[name].unit?.numerators ?? []),
...(parsedRules[name].unit?.denumerators ?? []),
],
[]
)
),
]
const blackList = ['€', '%']
const translatedKeys = Object.keys(unitsTranslations.en)
const missingTranslations = units.filter(
(unit) => ![...translatedKeys, ...blackList].includes(unit)
)
expect(missingTranslations).to.be.empty
})
})