2021-01-02 16:12:16 +01:00
|
|
|
import "jasmine";
|
|
|
|
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", () => {
|
2021-01-02 16:12:16 +01:00
|
|
|
it("Should not swap if all dice are crit successes.", () => {
|
|
|
|
expect(isDiceSwapNecessary([1, 1, 1], [], 9)).toBeFalse();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should not swap if no die is crit success.", () => {
|
|
|
|
expect(isDiceSwapNecessary([], [2, 2, 2], 9)).toBeFalse();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should not swap if all dice are already in use", () => {
|
|
|
|
expect(isDiceSwapNecessary([1], [9, 8], 10)).toBeFalse();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should not swap if result does not get any better", () => {
|
|
|
|
expect(isDiceSwapNecessary([1], [8], 4)).toBeFalse();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Should swap if result does get better", () => {
|
|
|
|
expect(isDiceSwapNecessary([1], [19], 18)).toBeTrue();
|
|
|
|
});
|
|
|
|
});
|