Correction d'un bug du méca sélection et les tests
parent
216337be31
commit
09926e567e
|
@ -627,7 +627,7 @@ export let mecanismSelection = (recurse,k,v) => {
|
|||
data = dataSource ? dataSource['data'] : null,
|
||||
dataKey = explanation.nodeValue,
|
||||
dataItems = (data && dataKey && dataSearchField) ? R.filter(item => item[dataSearchField] == dataKey, data) : null,
|
||||
dataItemValues = dataItems ? R.values(dataItems) : null,
|
||||
dataItemValues = (dataItems && !R.isEmpty(dataItems)) ? R.values(dataItems) : null,
|
||||
// TODO - over-specific! transform the JSON instead
|
||||
dataItemSubValues = dataItemValues && dataItemValues[0][dataTargetName] ? dataItemValues[0][dataTargetName]["taux"] : null,
|
||||
sortedSubValues = dataItemSubValues ? R.sortBy(pair => pair[0], R.toPairs(dataItemSubValues)) : null,
|
||||
|
|
|
@ -27,6 +27,15 @@ module.exports = {
|
|||
exclude: /node_modules/,
|
||||
loader: 'babel-loader'
|
||||
},
|
||||
{
|
||||
test: /\.csv$/,
|
||||
loader: 'csv-loader',
|
||||
options: {
|
||||
dynamicTyping: true,
|
||||
header: true,
|
||||
skipEmptyLines: true
|
||||
}
|
||||
},
|
||||
{ //slow : ~ 3 seconds
|
||||
test: /\.(jpe?g|png|gif|svg)$/i,
|
||||
loader: 'ignore-loader'
|
||||
|
|
|
@ -258,4 +258,22 @@ describe('analyseSituation with mecanisms', function() {
|
|||
expect(analyseSituation(rules,"startHere")(stateSelector)).to.have.property('nodeValue',0.02)
|
||||
});
|
||||
|
||||
it('should handle failed selections', function() {
|
||||
let stateSelector = (name) => ({"top . code postal":"3"})[name]
|
||||
let data = {taux_versement_transport: {xyz: {codePostal:1, aot: {taux: {"2019":"1.0"}}}, abc: {codePostal:2, smt: {taux: {"2019":"2.0"}}}}}
|
||||
let rawRules = [
|
||||
{ espace: "top",
|
||||
nom: "startHere",
|
||||
formule: {"sélection": {
|
||||
données: "startHere",
|
||||
cherche: "code postal",
|
||||
dans: "codePostal",
|
||||
renvoie: "smt"
|
||||
}},
|
||||
données: 'taux_versement_transport'},
|
||||
{espace: "top", nom: "code postal", format: "nombre"}],
|
||||
rules = rawRules.map(rule => enrichRule(rule,data))
|
||||
expect(analyseSituation(rules,"startHere")(stateSelector)).to.have.property('nodeValue', 0)
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue