Add docs, type clarifications.

This commit is contained in:
Oliver Rümpelein 2021-01-04 21:21:06 +01:00
parent fc88ce6c52
commit e2a42aee4b
4 changed files with 147 additions and 33 deletions

View file

@ -3,22 +3,22 @@ import { isDiceSwapNecessary } from "../../../src/module/rolls/roll-utils";
describe("Utility function testing if dice swap is necessary", () => {
it("Should not swap if all dice are crit successes.", () => {
expect(isDiceSwapNecessary([1, 1, 1], [], 9)).toBeFalse();
expect(isDiceSwapNecessary([[1, 1, 1], []], 9)).toBeFalse();
});
it("Should not swap if no die is crit success.", () => {
expect(isDiceSwapNecessary([], [2, 2, 2], 9)).toBeFalse();
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();
expect(isDiceSwapNecessary([[1], [9, 8]], 10)).toBeFalse();
});
it("Should not swap if result does not get any better", () => {
expect(isDiceSwapNecessary([1], [8], 4)).toBeFalse();
expect(isDiceSwapNecessary([[1], [8]], 4)).toBeFalse();
});
it("Should swap if result does get better", () => {
expect(isDiceSwapNecessary([1], [19], 18)).toBeTrue();
expect(isDiceSwapNecessary([[1], [19]], 18)).toBeTrue();
});
});