Fixed parse errors not showing up on calculations

This commit is contained in:
Stefan Zermatten
2021-09-27 16:39:44 +02:00
parent 111040e789
commit 85e8756d1d
3 changed files with 27 additions and 1 deletions

View File

@@ -24,7 +24,11 @@ function evaluateCalculation(calculation, scope){
} else {
calculation.value = NaN;
}
calculation.errors = context.errors;
if (calculation.errors){
calculation.errors = [...calculation.errors, ...context.errors]
} else {
calculation.errors = context.errors
}
}
function embedInlineCalculations(inlineCalcObj){

View File

@@ -13,6 +13,10 @@ export default function(){
assert.equal(prop('strengthId').modifier, 1);
assert.equal(prop('referencesDexId').value, 4);
assert.equal(prop('hitDiceId').constitutionMod, 5);
assert.equal(
prop('parseErrorId').baseValue.errors.length, 1,
'Parse errors should be added to calculation errors'
);
}
var testProperties = [
@@ -74,4 +78,13 @@ var testProperties = [
calculation: '4'
},
}),
clean({
_id: 'parseErrorId',
variableName: 'parseError',
type: 'attribute',
attributeType: 'ability',
baseValue: {
calculation: '12 +'
},
}),
];