Fixed inactive test for new parenting structure
This commit is contained in:
@@ -2,8 +2,9 @@ import { buildComputationFromProps } from '/imports/api/engine/computation/build
|
|||||||
import { assert } from 'chai';
|
import { assert } from 'chai';
|
||||||
import clean from '../../utility/cleanProp.testFn.js';
|
import clean from '../../utility/cleanProp.testFn.js';
|
||||||
|
|
||||||
export default function(){
|
export default function () {
|
||||||
let computation = buildComputationFromProps(testProperties);
|
let computation = buildComputationFromProps(testProperties);
|
||||||
|
|
||||||
const bySelf = (propId, note) => assertDeactivatedBySelf(computation, propId, note);
|
const bySelf = (propId, note) => assertDeactivatedBySelf(computation, propId, note);
|
||||||
const byAncestor = (propId, note) => assertDeactivatedByAncestor(computation, propId, note);
|
const byAncestor = (propId, note) => assertDeactivatedByAncestor(computation, propId, note);
|
||||||
const active = (propId, note) => assertActive(computation, propId, note);
|
const active = (propId, note) => assertActive(computation, propId, note);
|
||||||
@@ -24,22 +25,22 @@ export default function(){
|
|||||||
|
|
||||||
// Notes
|
// Notes
|
||||||
active('NoteId', 'Notes should be active');
|
active('NoteId', 'Notes should be active');
|
||||||
byAncestor('NoteChildId', 'children of notes should always be inactive');
|
active('NoteChildId', 'children of notes should be active');
|
||||||
}
|
}
|
||||||
|
|
||||||
function assertDeactivatedBySelf(computation, propId, note){
|
function assertDeactivatedBySelf(computation, propId, note) {
|
||||||
const prop = computation.propsById[propId];
|
const prop = computation.propsById[propId];
|
||||||
assert.isTrue(prop.deactivatedBySelf, note);
|
assert.isTrue(prop.deactivatedBySelf, note);
|
||||||
assert.isTrue(prop.inactive, note + '. The property should be inactive');
|
assert.isTrue(prop.inactive, note + '. The property should be inactive');
|
||||||
}
|
}
|
||||||
|
|
||||||
function assertDeactivatedByAncestor(computation, propId, note){
|
function assertDeactivatedByAncestor(computation, propId, note) {
|
||||||
const prop = computation.propsById[propId];
|
const prop = computation.propsById[propId];
|
||||||
assert.isTrue(prop.deactivatedByAncestor, note);
|
assert.isTrue(prop.deactivatedByAncestor, note);
|
||||||
assert.isTrue(prop.inactive, 'The property should be inactive');
|
assert.isTrue(prop.inactive, 'The property should be inactive');
|
||||||
}
|
}
|
||||||
|
|
||||||
function assertActive(computation, propId, note){
|
function assertActive(computation, propId, note) {
|
||||||
const prop = computation.propsById[propId];
|
const prop = computation.propsById[propId];
|
||||||
assert.isNotTrue(prop.inactive, note);
|
assert.isNotTrue(prop.inactive, note);
|
||||||
assert.isNotTrue(prop.deactivatedBySelf, note);
|
assert.isNotTrue(prop.deactivatedBySelf, note);
|
||||||
@@ -51,66 +52,90 @@ var testProperties = [
|
|||||||
clean({
|
clean({
|
||||||
_id: 'itemUnequippedId',
|
_id: 'itemUnequippedId',
|
||||||
type: 'item',
|
type: 'item',
|
||||||
ancestors: [{id: 'charId'}],
|
parentId: 'charId',
|
||||||
|
left: 1,
|
||||||
|
right: 4,
|
||||||
}),
|
}),
|
||||||
clean({
|
clean({
|
||||||
_id: 'itemUnequippedChildId',
|
_id: 'itemUnequippedChildId',
|
||||||
type: 'folder',
|
type: 'folder',
|
||||||
ancestors: [{id: 'charId'}, {id: 'itemUnequippedId'}],
|
parentId: 'itemUnequippedId',
|
||||||
|
left: 2,
|
||||||
|
right: 3,
|
||||||
}),
|
}),
|
||||||
clean({
|
clean({
|
||||||
_id: 'itemEquippedId',
|
_id: 'itemEquippedId',
|
||||||
type: 'item',
|
type: 'item',
|
||||||
equipped: true,
|
equipped: true,
|
||||||
ancestors: [{id: 'charId'}],
|
parentId: 'charId',
|
||||||
|
left: 5,
|
||||||
|
right: 8,
|
||||||
}),
|
}),
|
||||||
clean({
|
clean({
|
||||||
_id: 'itemEquippedChildId',
|
_id: 'itemEquippedChildId',
|
||||||
type: 'folder',
|
type: 'folder',
|
||||||
ancestors: [{id: 'charId'}, {id: 'itemEquippedId'}],
|
parentId: 'itemEquippedId',
|
||||||
|
left: 6,
|
||||||
|
right: 7,
|
||||||
}),
|
}),
|
||||||
// Spells
|
// Spells
|
||||||
clean({
|
clean({
|
||||||
_id: 'spellPreparedId',
|
_id: 'spellPreparedId',
|
||||||
type: 'spell',
|
type: 'spell',
|
||||||
ancestors: [{id: 'charId'}],
|
parentId: 'charId',
|
||||||
prepared: true,
|
prepared: true,
|
||||||
|
left: 9,
|
||||||
|
right: 12,
|
||||||
}),
|
}),
|
||||||
clean({
|
clean({
|
||||||
_id: 'spellPreparedChildId',
|
_id: 'spellPreparedChildId',
|
||||||
type: 'folder',
|
type: 'folder',
|
||||||
ancestors: [{id: 'charId'}, {id: 'spellPreparedId'}],
|
parentId: 'spellPreparedId',
|
||||||
|
left: 10,
|
||||||
|
right: 11,
|
||||||
}),
|
}),
|
||||||
clean({
|
clean({
|
||||||
_id: 'spellAlwaysPreparedId',
|
_id: 'spellAlwaysPreparedId',
|
||||||
type: 'spell',
|
type: 'spell',
|
||||||
ancestors: [{id: 'charId'}],
|
parentId: 'charId',
|
||||||
alwaysPrepared: true,
|
alwaysPrepared: true,
|
||||||
|
left: 13,
|
||||||
|
right: 16,
|
||||||
}),
|
}),
|
||||||
clean({
|
clean({
|
||||||
_id: 'spellAlwaysPreparedChildId',
|
_id: 'spellAlwaysPreparedChildId',
|
||||||
type: 'folder',
|
type: 'folder',
|
||||||
ancestors: [{id: 'charId'}, {id: 'spellAlwaysPreparedId'}],
|
parentId: 'spellAlwaysPreparedId',
|
||||||
|
left: 14,
|
||||||
|
right: 15,
|
||||||
}),
|
}),
|
||||||
clean({
|
clean({
|
||||||
_id: 'spellUnpreparedId',
|
_id: 'spellUnpreparedId',
|
||||||
type: 'spell',
|
type: 'spell',
|
||||||
ancestors: [{id: 'charId'}],
|
parentId: 'charId',
|
||||||
|
left: 17,
|
||||||
|
right: 20,
|
||||||
}),
|
}),
|
||||||
clean({
|
clean({
|
||||||
_id: 'spellUnpreparedChildId',
|
_id: 'spellUnpreparedChildId',
|
||||||
type: 'folder',
|
type: 'folder',
|
||||||
ancestors: [{id: 'charId'}, {id: 'spellUnpreparedId'}],
|
parentId: 'spellUnpreparedId',
|
||||||
|
left: 18,
|
||||||
|
right: 19,
|
||||||
}),
|
}),
|
||||||
// Notes
|
// Notes
|
||||||
clean({
|
clean({
|
||||||
_id: 'NoteId',
|
_id: 'NoteId',
|
||||||
type: 'note',
|
type: 'note',
|
||||||
ancestors: [{id: 'charId'}],
|
parentId: 'charId',
|
||||||
|
left: 21,
|
||||||
|
right: 24,
|
||||||
}),
|
}),
|
||||||
clean({
|
clean({
|
||||||
_id: 'NoteChildId',
|
_id: 'NoteChildId',
|
||||||
type: 'folder',
|
type: 'folder',
|
||||||
ancestors: [{id: 'charId'}, {id: 'NoteId'}],
|
parentId: 'NoteId',
|
||||||
|
left: 22,
|
||||||
|
right: 23,
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { docsToForest as nodeArrayToTree } from '/imports/api/parenting/parentingFunctions';
|
import { docsToForest } from '/imports/api/parenting/parentingFunctions';
|
||||||
import { DenormalisedOnlyCreaturePropertySchema as denormSchema }
|
import { DenormalisedOnlyCreaturePropertySchema as denormSchema }
|
||||||
from '/imports/api/creature/creatureProperties/CreatureProperties';
|
from '/imports/api/creature/creatureProperties/CreatureProperties';
|
||||||
import { getProperties, getCreature, getVariables } from '/imports/api/engine/loadCreatures.js';
|
import { getProperties, getCreature, getVariables } from '/imports/api/engine/loadCreatures.js';
|
||||||
@@ -12,7 +12,7 @@ import computeToggleDependencies from './buildComputation/computeToggleDependenc
|
|||||||
import linkCalculationDependencies from './buildComputation/linkCalculationDependencies.js';
|
import linkCalculationDependencies from './buildComputation/linkCalculationDependencies.js';
|
||||||
import linkTypeDependencies from './buildComputation/linkTypeDependencies.js';
|
import linkTypeDependencies from './buildComputation/linkTypeDependencies.js';
|
||||||
import computeSlotQuantityFilled from './buildComputation/computeSlotQuantityFilled.js';
|
import computeSlotQuantityFilled from './buildComputation/computeSlotQuantityFilled.js';
|
||||||
import CreatureComputation from './CreatureComputation.ts';
|
import CreatureComputation from './CreatureComputation';
|
||||||
import removeSchemaFields from './buildComputation/removeSchemaFields.js';
|
import removeSchemaFields from './buildComputation/removeSchemaFields.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,7 +86,7 @@ export function buildComputationFromProps(properties, creature, variables) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Get all the properties as trees based on their ancestors
|
// Get all the properties as trees based on their ancestors
|
||||||
let forest = nodeArrayToTree(properties);
|
let forest = docsToForest(properties);
|
||||||
// Walk the property trees computing things that need to be inherited
|
// Walk the property trees computing things that need to be inherited
|
||||||
walkDown(forest, node => {
|
walkDown(forest, node => {
|
||||||
computeInactiveStatus(node);
|
computeInactiveStatus(node);
|
||||||
|
|||||||
Reference in New Issue
Block a user