2022-02-07 08:34:32 +00:00
|
|
|
import { it, expect, describe } from 'vitest'
|
2020-11-04 17:05:46 +00:00
|
|
|
import { parsePublicodes } from 'publicodes'
|
2020-01-27 11:17:26 +00:00
|
|
|
import { uniq } from 'ramda'
|
2020-12-09 11:41:58 +00:00
|
|
|
import rawRules from 'modele-social'
|
2020-12-17 11:06:32 +00:00
|
|
|
import unitsTranslations from '../source/locales/units.yaml'
|
2020-01-27 11:17:26 +00:00
|
|
|
|
2022-02-07 08:34:32 +00:00
|
|
|
describe('Tests units', function () {
|
|
|
|
it('use unit that exists in publicodes', function () {
|
2022-02-10 11:07:19 +00:00
|
|
|
const { parsedRules } = parsePublicodes(rawRules)
|
2022-02-07 08:34:32 +00:00
|
|
|
const units = uniq(
|
2022-02-10 11:07:19 +00:00
|
|
|
Object.keys(parsedRules).reduce(
|
2022-02-07 08:34:32 +00:00
|
|
|
(prev, name) => [
|
|
|
|
...prev,
|
2022-02-10 11:07:19 +00:00
|
|
|
...(parsedRules[name].unit?.numerators ?? []),
|
|
|
|
...(parsedRules[name].unit?.denumerators ?? []),
|
2022-02-07 08:34:32 +00:00
|
|
|
],
|
|
|
|
[]
|
|
|
|
)
|
2020-01-27 11:17:26 +00:00
|
|
|
)
|
|
|
|
|
2022-02-07 08:34:32 +00:00
|
|
|
const blackList = ['€', '%']
|
|
|
|
const translatedKeys = Object.keys(unitsTranslations.en)
|
|
|
|
const missingTranslations = units.filter(
|
|
|
|
(unit) => ![...translatedKeys, ...blackList].includes(unit)
|
|
|
|
)
|
|
|
|
expect(missingTranslations).to.be.empty
|
|
|
|
})
|
2020-01-27 11:17:26 +00:00
|
|
|
})
|