chore/update_publicodes
Jalil Arfaoui 2024-12-03 22:07:44 +01:00
parent 5e898cf8fa
commit 719f0a3fb4
3 changed files with 46 additions and 4 deletions

View File

@ -0,0 +1,42 @@
import rules, { DottedName } from 'modele-social'
import Engine from 'publicodes'
import { beforeEach, describe, expect, it } from 'vitest'
describe('scénario tout simple', () => {
let engine: Engine<DottedName>
beforeEach(() => {
engine = new Engine(rules)
})
it('works', () => {
engine.setSituation({
"entreprise . chiffre d'affaires": {
valeur: 100000,
unité: '€/an',
},
'entreprise . catégorie juridique': "'EI'",
'entreprise . catégorie juridique . EI . auto-entrepreneur': 'oui',
'entreprise . activité . nature': "'libérale'",
'entreprise . activité . nature . libérale . réglementée': 'non',
salarié: 'non',
'dirigeant . auto-entrepreneur': 'oui',
})
// expect(engine).toEvaluate(
// {
// valeur: 'dirigeant . auto-entrepreneur . revenu net',
// unité: '€/an',
// },
// 76700
// )
expect(engine).toEvaluate(
{
valeur: 'dirigeant . rémunération . net . après impôt',
unité: '€/an',
},
63614
)
})
})

View File

@ -1,14 +1,14 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { DottedName } from 'modele-social'
import Engine, { Evaluation } from 'publicodes'
import Engine, { Evaluation, PublicodesExpression } from 'publicodes'
import { expect } from 'vitest'
import { PublicodesTypes } from '../helpers/PublicodesTypes'
const toEvaluate = function <T extends PublicodesTypes>(
engine: Engine,
rule: DottedName,
rule: PublicodesExpression,
value: Evaluation<T>
) {
const evaluated = engine.evaluate(rule).nodeValue

View File

@ -1,13 +1,13 @@
import 'vitest'
import { DottedName } from 'modele-social'
import { Evaluation } from 'publicodes'
import { Evaluation, PublicodesExpression } from 'publicodes'
import { PublicodesTypes } from './modele-social/helpers/PublicodesTypes'
interface CustomMatchers<R = unknown> {
toEvaluate: <T extends PublicodesTypes>(
rule: DottedName,
rule: PublicodesExpression,
value: Evaluation<T>
) => R
toBeApplicable: (rule: DottedName) => R