🐎 rends paresseuse l'évaluation du mécanisme "toutes ces conditions"
parent
991fa0c40e
commit
2223bd2792
|
@ -28,13 +28,13 @@ describe('Simulateurs', function() {
|
|||
cy.get(chargeInputSelector).type(1000)
|
||||
}
|
||||
cy.get(inputSelector).each((testedInput, i) => {
|
||||
cy.wrap(testedInput).type('{selectall}60003')
|
||||
cy.wrap(testedInput).type('{selectall}60100')
|
||||
cy.wait(1500)
|
||||
cy.contains('Cotisations')
|
||||
cy.get(inputSelector).each(($input, j) => {
|
||||
const val = $input.val().replace(/[\s,.]/g, '')
|
||||
if (i != j) {
|
||||
expect(val).not.to.be.eq('60003')
|
||||
expect(val).not.to.be.eq('60100')
|
||||
}
|
||||
expect(val).to.match(/[1-9][\d]{3,6}$/)
|
||||
})
|
||||
|
|
|
@ -4,16 +4,28 @@ import { Mecanism } from '../components/mecanisms/common'
|
|||
import { evaluateNode, makeJsx, mergeAllMissing } from '../evaluation'
|
||||
|
||||
const evaluate = (cache, situation, parsedRules, node) => {
|
||||
const evaluateOne = child =>
|
||||
evaluateNode(cache, situation, parsedRules, child)
|
||||
const explanation = map(evaluateOne, node.explanation)
|
||||
const anyFalse = explanation.find(e => e.nodeValue === false) // court-circuit
|
||||
const { nodeValue, missingVariables } = anyFalse ?? {
|
||||
nodeValue: explanation.some(e => e.nodeValue === null) ? null : true,
|
||||
const [nodeValue, explanation] = node.explanation.reduce(
|
||||
([nodeValue, explanation], node) => {
|
||||
if (nodeValue === false) {
|
||||
return [nodeValue, [...explanation, node]]
|
||||
}
|
||||
const evaluatedNode = evaluateNode(cache, situation, parsedRules, node)
|
||||
return [
|
||||
nodeValue === false || nodeValue === null
|
||||
? nodeValue
|
||||
: evaluatedNode.nodeValue,
|
||||
[...explanation, evaluatedNode]
|
||||
]
|
||||
},
|
||||
[true, []]
|
||||
)
|
||||
|
||||
return {
|
||||
...node,
|
||||
nodeValue,
|
||||
explanation,
|
||||
missingVariables: mergeAllMissing(explanation)
|
||||
}
|
||||
|
||||
return { ...node, nodeValue, explanation, missingVariables }
|
||||
}
|
||||
|
||||
export const mecanismAllOf = (recurse, v) => {
|
||||
|
|
Loading…
Reference in New Issue