wip wtf
parent
5e898cf8fa
commit
719f0a3fb4
|
@ -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
|
||||
)
|
||||
})
|
||||
})
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue