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

@@ -43,7 +43,7 @@ export function migrateProperty({ collection, reversed, prop }) {
let migratedProp = transformFields(prop, transforms, reversed);
const schema = collection.simpleSchema({ type: migratedProp.type });
// Only clean if the schema version matches our destination version
if (!reversed && SCHEMA_VERSION >= 1) {
if (!reversed && SCHEMA_VERSION == 1) {
try {
migratedProp = schema.clean(migratedProp);
schema.validate(migratedProp);
@@ -81,6 +81,7 @@ const transformsByPropType = {
...getComputedPropertyTransforms('rollBonus', 'attackRoll'),
//change type to action
{ from: 'type', to: 'type', up: () => 'action' },
{ from: 'results' },
],
'attribute': [
// from: baseValue must be first or else it will delete the field we need

View File

@@ -124,7 +124,6 @@ const expectedMigratedAttribute = {
damage: 3,
value: 17,
constitutionMod: 2,
dirty: true,
}
const exampleAttack = {
@@ -183,6 +182,7 @@ const expectedMigratedAttack = {
},
'attackRoll': {
calculation: 'dexterity.modifier + proficiencyBonus + 2 - hp.total + hp.value',
value: 6,
},
'type': 'action',
'name': 'Claws',
@@ -221,7 +221,6 @@ describe('migrateProperty', function () {
prop: newAction,
reversed: true,
});
delete reversedAction.dirty;
assert.deepEqual(action, exampleAction, 'action should not be bashed');
assert.deepEqual(exampleAction, reversedAction, 'operation should be reversible');
});
@@ -237,14 +236,14 @@ describe('migrateProperty', function () {
'Attribute should match the expected result');
});
it('Migrates attacks as expected', function () {
const attribute = {
const attack = {
...exampleAttack
};
const newAttribute = migrateProperty({
const newAttack = migrateProperty({
collection: LibraryNodes,
prop: attribute
prop: attack
});
assert.deepEqual(newAttribute, expectedMigratedAttack,
'Attribute should match the expected result');
assert.deepEqual(newAttack, expectedMigratedAttack,
'Attack should match the expected result');
});
});