🐛 Corrige les variables manquantes pour 'une possibilité' lorsqu'on a donné une réponse
parent
5281d5990c
commit
25b7263658
|
@ -91,9 +91,12 @@ let fillVariableNode = (rules, rule) => (parseResult) => {
|
|||
? null // pas moyen de calculer car il n'y a pas de formule, elle restera donc nulle
|
||||
: parsedRule.nodeValue, // la valeur du calcul fait foi
|
||||
explanation = parsedRule,
|
||||
missingVariables = variableIsCalculable ? [] : (nodeValue == null ? [dottedName] : [])
|
||||
missingVariables = variableIsCalculable ? [] : [dottedName]
|
||||
|
||||
let collectMissing = node => variableIsCalculable ? collectNodeMissing(parsedRule) : node.missingVariables
|
||||
let collectMissing = node =>
|
||||
nodeValue != null ? // notamment si situationValue != null
|
||||
[] :
|
||||
variableIsCalculable ? collectNodeMissing(parsedRule) : node.missingVariables
|
||||
|
||||
let result = cached ? cached : {
|
||||
...rewriteNode(node,nodeValue,explanation,collectMissing),
|
||||
|
|
|
@ -93,6 +93,19 @@ describe('collectMissingVariables', function() {
|
|||
expect(result).to.deep.equal({})
|
||||
});
|
||||
|
||||
it('should not report missing variables when "une possibilité" was answered', function() {
|
||||
let mySelector = (name) => ({"top . trois":"ko"})[name]
|
||||
|
||||
let rawRules = [
|
||||
{nom: "startHere", formule: "trois", espace: "top"},
|
||||
{nom: "trois", formule: {"une possibilité":["ko"]}, espace: "top"}],
|
||||
rules = rawRules.map(enrichRule),
|
||||
situation = analyseTopDown(rules,"startHere")(mySelector),
|
||||
result = collectMissingVariables()(mySelector,situation)
|
||||
|
||||
expect(result).to.deep.equal({})
|
||||
});
|
||||
|
||||
it('should report missing variables in switch statements', function() {
|
||||
let rawRules = [
|
||||
{ nom: "startHere", formule: {"aiguillage numérique": {
|
||||
|
|
Loading…
Reference in New Issue