Fixed more failing tests to match nested sets

This commit is contained in:
ThaumRystra
2023-09-28 20:57:35 +02:00
parent 60c13643fb
commit 09c66aff0b
19 changed files with 198 additions and 78 deletions

View File

@@ -3,7 +3,7 @@ import { assert } from 'chai';
import computeCreatureComputation from '../../computeCreatureComputation.js';
import clean from '../../utility/cleanProp.testFn.js';
export default function(){
export default function () {
const computation = buildComputationFromProps(testProperties);
computeCreatureComputation(computation);
@@ -33,7 +33,6 @@ var testProperties = [
clean({
_id: 'actionId',
type: 'action',
ancestors: [{id: 'charId'}],
summary: {
text: 'test summary {1 + 2} without referencing anything {3 + 4}',
},
@@ -61,14 +60,17 @@ var testProperties = [
calculation: 'nonExistantProperty + 7',
},
usesUsed: 5,
left: 1,
right: 2,
}),
clean({
_id: 'rolledDescriptionId',
type: 'action',
ancestors: [{id: 'charId'}],
summary: {
text: 'test roll gets compiled {4 + (2 + 2)} properly',
},
left: 3,
right: 4,
}),
clean({
_id: 'numItemsConumedId',
@@ -77,6 +79,8 @@ var testProperties = [
baseValue: {
calculation: '3',
},
left: 5,
right: 6,
}),
clean({
_id: 'numResourceConumedId',
@@ -85,6 +89,8 @@ var testProperties = [
baseValue: {
calculation: '4',
},
left: 7,
right: 8,
}),
clean({
_id: 'resourceVarId',
@@ -94,6 +100,8 @@ var testProperties = [
baseValue: {
calculation: '9',
},
left: 9,
right: 10,
}),
clean({
_id: 'inlineRefResourceId',
@@ -102,6 +110,8 @@ var testProperties = [
baseValue: {
calculation: '1 + 5',
},
left: 11,
right: 12,
}),
clean({
_id: 'arrowId',
@@ -110,5 +120,7 @@ var testProperties = [
quantity: 27,
icon: 'itemIcon',
color: 'itemColor',
left: 13,
right: 14,
}),
];

View File

@@ -3,7 +3,7 @@ import { assert } from 'chai';
import computeCreatureComputation from '../../computeCreatureComputation.js';
import clean from '../../utility/cleanProp.testFn.js';
export default function(){
export default function () {
const computation = buildComputationFromProps(testProperties);
computeCreatureComputation(computation);
const prop = id => computation.propsById[id];
@@ -27,6 +27,8 @@ var testProperties = [
_id: 'emptyId',
type: 'attribute',
attributeType: 'ability',
left: 1,
right: 2,
}),
clean({
_id: 'noVariableNameId',
@@ -35,6 +37,8 @@ var testProperties = [
baseValue: {
calculation: '8'
},
left: 3,
right: 4,
}),
clean({
_id: 'strengthId',
@@ -44,6 +48,8 @@ var testProperties = [
baseValue: {
calculation: '12'
},
left: 5,
right: 6,
}),
clean({
_id: 'overriddenDexId',
@@ -54,6 +60,8 @@ var testProperties = [
baseValue: {
calculation: '15'
},
left: 7,
right: 8,
}),
clean({
_id: 'dexterityId',
@@ -64,6 +72,8 @@ var testProperties = [
baseValue: {
calculation: '15'
},
left: 9,
right: 10,
}),
clean({
_id: 'constitutionId',
@@ -73,6 +83,8 @@ var testProperties = [
baseValue: {
calculation: '21'
},
left: 11,
right: 12,
}),
clean({
_id: 'referencesDexId',
@@ -81,6 +93,8 @@ var testProperties = [
baseValue: {
calculation: 'dexterity.modifier + 2'
},
left: 13,
right: 14,
}),
clean({
_id: 'hitDiceId',
@@ -91,6 +105,8 @@ var testProperties = [
baseValue: {
calculation: '4'
},
left: 15,
right: 16,
}),
clean({
_id: 'parseErrorId',
@@ -100,5 +116,7 @@ var testProperties = [
baseValue: {
calculation: '12 +'
},
left: 17,
right: 18,
}),
];

View File

@@ -2,8 +2,9 @@ import { buildComputationFromProps } from '/imports/api/engine/computation/build
import { assert } from 'chai';
import computeCreatureComputation from '../../computeCreatureComputation.js';
import clean from '../../utility/cleanProp.testFn.js';
import { applyNestedSetProperties, compareOrder } from '/imports/api/parenting/parentingFunctions';
export default function(){
export default function () {
const computation = buildComputationFromProps(testProperties);
computeCreatureComputation(computation);
const prop = id => computation.propsById[id];
@@ -13,9 +14,8 @@ export default function(){
assert.equal(scope('valueEquipment'), 3);
assert.equal(scope('itemsAttuned'), 1);
assert.equal(prop('childContainerId').carriedWeight, 69);
assert.equal(prop('childContainerId').contentsWeight, 69);
assert.equal(prop('childContainerId').carriedWeight, 69, 'Calculates container carried weight correctly');
assert.equal(prop('childContainerId').contentsWeight, 69, 'Calculates container contents weight correctly');
assert.equal(scope('weightCarried'), 104);
assert.equal(scope('valueCarried'), 129);
@@ -32,7 +32,6 @@ var testProperties = [
attuned: true,
weight: 2,
value: 3,
ancestors: [{id: 'charId'}],
}),
clean({
_id: 'containerId',
@@ -40,22 +39,13 @@ var testProperties = [
carried: true,
weight: 5,
value: 7,
ancestors: [{id: 'charId'}],
}),
clean({
_id: 'childContainerId',
type: 'container',
carried: true,
weight: 11,
value: 13,
ancestors: [{id: 'charId'}, {id: 'containerId'}],
}),
clean({
_id: 'childItemId',
type: 'item',
weight: 17,
value: 19,
ancestors: [{id: 'charId'}, {id: 'containerId'}],
parentId: 'containerId',
}),
clean({
_id: 'grandchildItemId',
@@ -63,6 +53,16 @@ var testProperties = [
weight: 23, // 69 total
value: 29, // 87 total
quantity: 3,
ancestors: [{id: 'charId'}, {id: 'containerId'}, {id: 'childContainerId'}],
parentId: 'childContainerId',
}),
clean({
_id: 'childContainerId',
type: 'container',
carried: true,
weight: 11,
value: 13,
parentId: 'containerId',
}),
];
applyNestedSetProperties(testProperties);
testProperties.sort(compareOrder);

View File

@@ -2,9 +2,11 @@ import { buildComputationFromProps } from '/imports/api/engine/computation/build
import { assert } from 'chai';
import computeCreatureComputation from '../../computeCreatureComputation.js';
import clean from '../../utility/cleanProp.testFn.js';
import { applyNestedSetProperties, compareOrder } from '/imports/api/parenting/parentingFunctions';
export default function () {
const computation = buildComputationFromProps(testProperties);
const hasLink = computation.dependencyGraph.hasLink;
computeCreatureComputation(computation);
const prop = id => computation.propsById[id];
assert.equal(
@@ -15,6 +17,10 @@ export default function () {
prop('strengthId').modifier, -1,
'The proficiency bonus should not change the strength modifier'
);
assert.isTrue(
!!hasLink('actionId.attackRoll', 'tagTargetedProficiency'),
'There should be a link from the proficiency to the attack roll'
);
assert.exists(prop('actionId').attackRoll.proficiencies, 'The proficiency aggregator should be here')
assert.exists(prop('actionId').attackRoll.proficiencies[0], 'The proficiency should be here')
// attack roll = strength.mod + proficiencyBonus/2 rounded down
@@ -62,3 +68,5 @@ var testProperties = [
targetTags: ['martial weapon']
}),
];
applyNestedSetProperties(testProperties);
testProperties.sort(compareOrder);