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

29 lines
841 B
JavaScript
Raw Normal View History

import { it, expect, describe } from 'vitest'
import { parsePublicodes } from 'publicodes'
import { uniq } from 'ramda'
import rawRules from 'modele-social'
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 = uniq(
2022-02-10 11:07:19 +00:00
Object.keys(parsedRules).reduce(
(prev, name) => [
...prev,
2022-02-10 11:07:19 +00:00
...(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
})
})