ds4/spec/rolls/roll-utils.spec.ts

24 lines
846 B
TypeScript
Raw Permalink Normal View History

2021-02-11 13:42:38 +01:00
import { isDiceSwapNecessary } from "../../src/module/rolls/roll-utils";
2021-01-03 14:49:21 +01:00
describe("Utility function testing if dice swap is necessary", () => {
it("Should not swap if all dice are crit successes.", () => {
2021-02-11 13:42:38 +01:00
expect(isDiceSwapNecessary([[1, 1, 1], []], 9)).toBeFalsy();
});
it("Should not swap if no die is crit success.", () => {
2021-02-11 13:42:38 +01:00
expect(isDiceSwapNecessary([[], [2, 2, 2]], 9)).toBeFalsy();
});
it("Should not swap if all dice are already in use", () => {
2021-02-11 13:42:38 +01:00
expect(isDiceSwapNecessary([[1], [9, 8]], 10)).toBeFalsy();
});
it("Should not swap if result does not get any better", () => {
2021-02-11 13:42:38 +01:00
expect(isDiceSwapNecessary([[1], [8]], 4)).toBeFalsy();
});
it("Should swap if result does get better", () => {
2021-02-11 13:42:38 +01:00
expect(isDiceSwapNecessary([[1], [19]], 18)).toBeTruthy();
});
});