From ac458cbd7949dc7cb9fbe568b08857efee4dab99 Mon Sep 17 00:00:00 2001 From: Laurent Bossavit Date: Fri, 7 Jul 2017 09:09:39 +0200 Subject: [PATCH] :white_check_mark: Tester les variables manquantes dans les expressions --- test/rules.test.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/rules.test.js b/test/rules.test.js index cd4f9939c..9465d15d0 100644 --- a/test/rules.test.js +++ b/test/rules.test.js @@ -53,6 +53,20 @@ describe('collectMissingVariables', function() { expect(result).to.have.property('sum . evt . ko') }); + it('should identify missing variables mentioned in expressions', function() { + let rawRules = [ + {nom: "startHere", formule: {somme: [2, "deux"]}, espace: "sum"}, + {nom: "deux", formule: 2, "non applicable si" : "evt . nyet > evt . nope", espace: "sum"}, + {nom: "nope", espace: "sum . evt"}, + {nom: "nyet", espace: "sum . evt"}], + rules = rawRules.map(enrichRule), + situation = analyseSituation(rules,"startHere")(stateSelector), + result = collectMissingVariables()(situation) + + expect(result).to.have.property('sum . evt . nyet') + expect(result).to.have.property('sum . evt . nope') + }); + }); describe('findVariantsAndRecords', function() {