Fix tests.

This commit is contained in:
Oliver Rümpelein 2021-01-07 02:33:22 +01:00
parent 1422f28760
commit 14ffff1985
2 changed files with 14 additions and 10 deletions

View file

@ -110,7 +110,7 @@ describe("DS4 Rolls with multiple dice and no modifiers.", () => {
it("Should succeed normally with all rolls crit successes.", () => { it("Should succeed normally with all rolls crit successes.", () => {
expect(rollCheckMultipleDice(48, {}, [1, 1, 1])).toEqual( expect(rollCheckMultipleDice(48, {}, [1, 1, 1])).toEqual(
new RollResult(48, RollResultStatus.SUCCESS, [1, 1, 1]), new RollResult(48, RollResultStatus.CRITICAL_SUCCESS, [1, 1, 1]),
); );
}); });
@ -151,16 +151,20 @@ describe("DS4 Rolls with multiple dice and no modifiers.", () => {
}); });
it("Should maximize on 2-dice 'lowest dice higher than last CTN and crit success thrown'-Edge case, no change required.", () => { it("Should maximize on 2-dice 'lowest dice higher than last CTN and crit success thrown'-Edge case, no change required.", () => {
expect(rollCheckMultipleDice(24, {}, [1, 8])).toEqual(new RollResult(20, RollResultStatus.SUCCESS, [1, 8])); expect(rollCheckMultipleDice(24, {}, [1, 8])).toEqual(
new RollResult(20, RollResultStatus.CRITICAL_SUCCESS, [1, 8]),
);
}); });
it("Should maximize on 2-dice 'lowest dice higher than last CTN and crit success thrown'-Edge case, change required.", () => { it("Should maximize on 2-dice 'lowest dice higher than last CTN and crit success thrown'-Edge case, change required.", () => {
expect(rollCheckMultipleDice(38, {}, [1, 19])).toEqual(new RollResult(37, RollResultStatus.SUCCESS, [1, 19])); expect(rollCheckMultipleDice(38, {}, [1, 19])).toEqual(
new RollResult(37, RollResultStatus.CRITICAL_SUCCESS, [1, 19]),
);
}); });
it("Should maximize correctly when swapping with more than one crit success", () => { it("Should maximize correctly when swapping with more than one crit success", () => {
expect(rollCheckMultipleDice(48, {}, [1, 1, 15])).toEqual( expect(rollCheckMultipleDice(48, {}, [1, 1, 15])).toEqual(
new RollResult(43, RollResultStatus.SUCCESS, [1, 1, 15]), new RollResult(43, RollResultStatus.CRITICAL_SUCCESS, [1, 1, 15]),
); );
}); });
}); });
@ -174,7 +178,7 @@ describe("DS4 Rolls with multiple dice and min/max modifiers.", () => {
it("Should succeed with all rolls crit successes (1 and 2).", () => { it("Should succeed with all rolls crit successes (1 and 2).", () => {
expect(rollCheckMultipleDice(48, { maxCritSucc: 2, minCritFail: 19 }, [2, 1, 2])).toEqual( expect(rollCheckMultipleDice(48, { maxCritSucc: 2, minCritFail: 19 }, [2, 1, 2])).toEqual(
new RollResult(48, RollResultStatus.SUCCESS, [2, 1, 2]), new RollResult(48, RollResultStatus.CRITICAL_SUCCESS, [2, 1, 2]),
); );
}); });
@ -214,7 +218,7 @@ describe("DS4 Rolls with multiple dice and fail modifiers.", () => {
describe("DS4 Rolls with multiple dice and success modifiers.", () => { describe("DS4 Rolls with multiple dice and success modifiers.", () => {
it("Should succeed with all rolls crit successes (1 and 2).", () => { it("Should succeed with all rolls crit successes (1 and 2).", () => {
expect(rollCheckMultipleDice(48, { maxCritSucc: 2 }, [2, 1, 2])).toEqual( expect(rollCheckMultipleDice(48, { maxCritSucc: 2 }, [2, 1, 2])).toEqual(
new RollResult(48, RollResultStatus.SUCCESS, [2, 1, 2]), new RollResult(48, RollResultStatus.CRITICAL_SUCCESS, [2, 1, 2]),
); );
}); });
}); });

View file

@ -36,8 +36,8 @@ export class RollResult {
} }
export enum RollResultStatus { export enum RollResultStatus {
FAILURE, FAILURE = "FAILURE",
SUCCESS, SUCCESS = "SUCCESS",
CRITICAL_FAILURE, CRITICAL_FAILURE = "CRITICAL_FAILURE",
CRITICAL_SUCCESS, CRITICAL_SUCCESS = "CRITICAL_SUCCESS",
} }