🐛 Ne pas remonter de variables manquantes d'autres conditions si une est satisfaite
parent
38a21ff91e
commit
34977eb234
|
@ -23,7 +23,7 @@ export let evaluateArray = (reducer, start, nullable = true) => (situationGate,
|
|||
values = R.pluck("nodeValue",explanation),
|
||||
nodeValue = (nullable && R.any(R.equals(null),values)) ? null : R.reduce(reducer, start, values)
|
||||
|
||||
let collectMissing = node => R.chain(collectNodeMissing,node.explanation)
|
||||
let collectMissing = node => node.nodeValue == null ? R.chain(collectNodeMissing,node.explanation) : []
|
||||
return rewriteNode(node,nodeValue,explanation,collectMissing)
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,18 @@ describe('collectMissingVariables', function() {
|
|||
expect(result).to.be.empty
|
||||
});
|
||||
|
||||
it('should not report missing variables when "one of these" short-circuits', function() {
|
||||
let rawRules = [
|
||||
{nom: "startHere", formule: {somme: [2, "deux"]}, espace: "sum"},
|
||||
{nom: "deux", formule: "trois", "non applicable si" : {"une de ces conditions": ["3 > 2", "trois"]}, espace: "sum"},
|
||||
{nom: "trois", espace: "sum"}],
|
||||
rules = rawRules.map(enrichRule),
|
||||
situation = analyseTopDown(rules,"startHere")(stateSelector),
|
||||
result = collectMissingVariables()(stateSelector,situation)
|
||||
|
||||
expect(result).to.be.empty
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('buildNextSteps', function() {
|
||||
|
|
Loading…
Reference in New Issue