Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kaelad02 committed May 21, 2024
1 parent 7e78543 commit 8117c6a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/reminders.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ export class AbilityCheckReminder extends AbilityBaseReminder {
}

get disadvantageConditions() {
return super.disadvantageConditions().push("advReminderDisadvantageAbility");
const conditions = super.disadvantageConditions;
conditions.push("advReminderDisadvantageAbility");
return conditions;
}
}

Expand Down Expand Up @@ -242,7 +244,8 @@ export class AbilitySaveReminder extends AbilityBaseReminder {
}

get disadvantageConditions() {
const conditions = super.disadvantageConditions().push("advReminderDisadvantageSave");
const conditions = super.disadvantageConditions;
conditions.push("advReminderDisadvantageSave");
if (this.abilityId === "dex") conditions.push("advReminderDisadvantageDexSave");
return conditions;
}
Expand Down
23 changes: 23 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,36 @@ export default function commonTestInit() {
globalThis.createActorWithFlags = (...keys) => {
const actor = {
flags: {},
hasConditionEffect: () => false,
system: {},
};
keys.forEach((k) => setProperty(actor, k, true));
return actor;
};

globalThis.CONFIG = {};
globalThis.CONFIG.DND5E = {};
globalThis.CONFIG.DND5E.conditionEffects = {};

// copied from Foundry

function filter(test) {
const filtered = new Set();
let i = 0;
for ( const v of this ) {
if ( test(v, i, this) ) filtered.add(v);
i++;
}
return filtered;
}
function toObject() {
return Array.from(this);
}
Object.defineProperties(Set.prototype, {
filter: {value: filter},
toObject: {value: toObject}
});

globalThis.setProperty = (object, key, value) => {
// split the key into parts, removing the last one
const parts = key.split(".");
Expand Down

0 comments on commit 8117c6a

Please sign in to comment.