Add regression test for modifier.getFormula respecting enabled #58

Merged
thepaperpilot merged 5 commits from thepaperpilot/Profectus:feat/getformula-regression-test into main 2024-02-21 01:25:53 +00:00
Showing only changes of commit 22581ba2a1 - Show all commits

View file

@ -205,13 +205,10 @@ describe("Sequential Modifiers", () => {
const modifier = createSequentialModifier(() => [
createMultiplicativeModifier(() => ({ multiplier: 5, enabled }))
]);
expect(modifier.getFormula(Formula.variable(value)).evaluate()).compare_tolerance(
value.value
);
const formula = modifier.getFormula(Formula.variable(value));
expect(formula.evaluate()).compare_tolerance(value.value);
enabled.value = true;
expect(modifier.getFormula(Formula.variable(value)).evaluate()).not.compare_tolerance(
value.value
);
expect(formula.evaluate()).not.compare_tolerance(value.value);
});
thepaperpilot marked this conversation as resolved
Review

For this test, we should be making the formula once, then re-using it when the conditions change.
Should be more like

const formula = modifier.getFormula()
expect formula.evaluate() == value
enabled = true
expect formula.evaluate() != value
For this test, we should be making the formula once, then re-using it when the conditions change. Should be more like ``` const formula = modifier.getFormula() expect formula.evaluate() == value enabled = true expect formula.evaluate() != value ```
});