From 38dae84619966a6bcf22ef6029621e14dd84e46c Mon Sep 17 00:00:00 2001 From: Laurent Bossavit Date: Sun, 24 Sep 2017 18:21:37 +0200 Subject: [PATCH] =?UTF-8?q?:white=5Fcheck=5Fmark:=20Am=C3=A9liore=20le=20t?= =?UTF-8?q?est=20sur=20le=20cache=20des=20composantes=20filtr=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/traverse.test.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/test/traverse.test.js b/test/traverse.test.js index 85024531f..ab45df7da 100644 --- a/test/traverse.test.js +++ b/test/traverse.test.js @@ -219,21 +219,25 @@ describe('analyseSituation with mecanisms', function() { expect(analyseSituation(rules,"startHere")(stateSelector)).to.have.property('nodeValue',50+400+40) }); - // TODO - make this a smaller test case it('should compute consistent values', function() { - let stateSelector = (name) => ({ - "contrat salarié . CDD . événement . poursuite du CDD en CDI":"oui", - "contrat salarié . salaire brut":2300, - "contrat salarié . statut cadre":"non", - "entreprise . effectif":20 - })[name] - - let rules = realRules.map(enrichRule), - part = analyseTopDown(rules,"coût du travail")(stateSelector), - whole = analyseTopDown(rules,"Salaire")(stateSelector) - - expect(part.root.nodeValue).to.be.closeTo(2971.44,0.01) - expect(whole.root.formule.explanation.explanation[1].nodeValue).to.be.closeTo(2971.44,0.01) + let rawRules = [ + {nom: "startHere", espace: "top", formule: "composed (salarié) + composed (employeur)"}, + {nom: "orHere", espace: "top", formule: "composed"}, + {nom: "composed", espace: "top", formule: {"barème": { + assiette:2008, + "multiplicateur des tranches":1000, + composantes: [ + {tranches:[{"en-dessous de":1, taux: 0.05},{de:1, "à": 2, taux: 0.4}, ,{"au-dessus de":2, taux: 5}], + attributs: {"dû par":"salarié"} + }, + {tranches:[{"en-dessous de":1, taux: 0.05},{de:1, "à": 2, taux: 0.8}, ,{"au-dessus de":2, taux: 5}], + attributs: {"dû par":"employeur"} + } + ] + }}}], + rules = rawRules.map(enrichRule) + expect(analyseSituation(rules,"orHere")(stateSelector)).to.have.property('nodeValue',100+1200+80) + expect(analyseSituation(rules,"startHere")(stateSelector)).to.have.property('nodeValue',100+1200+80) }); });