Fixed parse errors not showing up on calculations
This commit is contained in:
@@ -5,6 +5,8 @@ import clean from '../../utility/cleanProp.testFn.js';
|
||||
export default function(){
|
||||
const computation = buildComputationFromProps(testProperties);
|
||||
const hasLink = computation.dependencyGraph.hasLink;
|
||||
const prop = (id) => computation.propsById[id];
|
||||
|
||||
assert.isTrue(
|
||||
!!hasLink('childId', 'spellListId'),
|
||||
'Ancestor references of parent in inline calculations should create dependency'
|
||||
@@ -21,6 +23,10 @@ export default function(){
|
||||
!!hasLink('grandchildId', 'wisdom'),
|
||||
'Variable references create dependencies even if the attributes don\'t exist'
|
||||
);
|
||||
assert.equal(
|
||||
prop('strengthId').baseValue.errors.length, 1,
|
||||
'Parse errors should be added to calculation errors'
|
||||
);
|
||||
}
|
||||
|
||||
var testProperties = [
|
||||
@@ -49,6 +55,9 @@ var testProperties = [
|
||||
_id: 'strengthId',
|
||||
type: 'attribute',
|
||||
variableName: 'strength',
|
||||
baseValue: {
|
||||
calculation: '15 + ',
|
||||
},
|
||||
ancestors: [{id: 'charId'}],
|
||||
}),
|
||||
];
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -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 +'
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user