From 719f0a3fb439ac923cf2de6c93920785a1502a92 Mon Sep 17 00:00:00 2001 From: Jalil Arfaoui Date: Tue, 3 Dec 2024 22:07:44 +0100 Subject: [PATCH] wip wtf --- .../comparateur-statuts/scenario_1.test.ts | 42 +++++++++++++++++++ .../test/modele-social/matchers/toEvaluate.ts | 4 +- site/test/vitest.d.ts | 4 +- 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 site/test/comparateur-statuts/scenario_1.test.ts diff --git a/site/test/comparateur-statuts/scenario_1.test.ts b/site/test/comparateur-statuts/scenario_1.test.ts new file mode 100644 index 000000000..635d4076e --- /dev/null +++ b/site/test/comparateur-statuts/scenario_1.test.ts @@ -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 + 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 + ) + }) +}) diff --git a/site/test/modele-social/matchers/toEvaluate.ts b/site/test/modele-social/matchers/toEvaluate.ts index 3202c36b0..585f494e5 100644 --- a/site/test/modele-social/matchers/toEvaluate.ts +++ b/site/test/modele-social/matchers/toEvaluate.ts @@ -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 ( engine: Engine, - rule: DottedName, + rule: PublicodesExpression, value: Evaluation ) { const evaluated = engine.evaluate(rule).nodeValue diff --git a/site/test/vitest.d.ts b/site/test/vitest.d.ts index 02900a284..e25a197e5 100644 --- a/site/test/vitest.d.ts +++ b/site/test/vitest.d.ts @@ -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 { toEvaluate: ( - rule: DottedName, + rule: PublicodesExpression, value: Evaluation ) => R toBeApplicable: (rule: DottedName) => R