2020-12-09 12:41:58 +01:00
|
|
|
import rawRules from 'modele-social'
|
2022-11-03 17:32:04 +01:00
|
|
|
import { parsePublicodes } from 'publicodes'
|
|
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
|
2020-12-17 12:06:32 +01:00
|
|
|
import unitsTranslations from '../source/locales/units.yaml'
|
2020-01-27 12:17:26 +01:00
|
|
|
|
2022-02-07 09:34:32 +01:00
|
|
|
describe('Tests units', function () {
|
|
|
|
it('use unit that exists in publicodes', function () {
|
2022-02-10 12:07:19 +01:00
|
|
|
const { parsedRules } = parsePublicodes(rawRules)
|
2022-05-03 14:56:13 +02:00
|
|
|
const units = [
|
|
|
|
...new Set(
|
|
|
|
Object.keys(parsedRules).reduce(
|
|
|
|
(prev, name) => [
|
|
|
|
...prev,
|
|
|
|
...(parsedRules[name].unit?.numerators ?? []),
|
|
|
|
...(parsedRules[name].unit?.denumerators ?? []),
|
|
|
|
],
|
|
|
|
[]
|
|
|
|
)
|
|
|
|
),
|
|
|
|
]
|
2020-01-27 12:17:26 +01:00
|
|
|
|
2022-02-07 09:34:32 +01: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 12:17:26 +01:00
|
|
|
})
|