Add additional single-roll tests.

This commit is contained in:
Oliver Rümpelein 2020-12-30 22:19:36 +01:00
parent 8d274ed830
commit 2178e745bc

View file

@ -2,7 +2,7 @@ import { rollCheckSingleDie, RollOptions, RollResult, RollResultStatus } from ".
import { RollProvider } from "../../src/module/rolls/roll-provider"; import { RollProvider } from "../../src/module/rolls/roll-provider";
describe("DS4 Rolls", () => { describe("DS4 Rolls", () => {
it("Should do a proper single success role", () => { it("Should do a proper single success roll.", () => {
const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRoll"]); const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRoll"]);
rollProvider.getNextRoll = jasmine.createSpy("getNextRoll").and.returnValue(4); rollProvider.getNextRoll = jasmine.createSpy("getNextRoll").and.returnValue(4);
@ -11,4 +11,54 @@ describe("DS4 Rolls", () => {
new RollResult(4, RollResultStatus.SUCCESS, [4]), new RollResult(4, RollResultStatus.SUCCESS, [4]),
); );
}); });
it("Should do a proper single success roll on success edge case.", () => {
const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRoll"]);
rollProvider.getNextRoll = jasmine.createSpy("getNextRoll").and.returnValue(4);
expect(rollCheckSingleDie(4, new RollOptions(), rollProvider)).toEqual(
new RollResult(4, RollResultStatus.SUCCESS, [4]),
);
});
it("Should do a proper single failure roll, lower bound", () => {
const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRoll"]);
rollProvider.getNextRoll = jasmine.createSpy("getNextRoll").and.returnValue(5);
expect(rollCheckSingleDie(4, new RollOptions(), rollProvider)).toEqual(
new RollResult(0, RollResultStatus.FAILURE, [5]),
);
});
it("Should do a proper single failure roll, upper bound", () => {
const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRoll"]);
rollProvider.getNextRoll = jasmine.createSpy("getNextRoll").and.returnValue(19);
expect(rollCheckSingleDie(4, new RollOptions(), rollProvider)).toEqual(
new RollResult(0, RollResultStatus.FAILURE, [19]),
);
});
it("Should do a proper single crit success roll.", () => {
const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRoll"]);
rollProvider.getNextRoll = jasmine.createSpy("getNextRoll").and.returnValue(1);
expect(rollCheckSingleDie(4, new RollOptions(), rollProvider)).toEqual(
new RollResult(4, RollResultStatus.CRITICAL_SUCCESS, [1]),
);
});
it("Should do a proper single crit failure roll.", () => {
const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRoll"]);
rollProvider.getNextRoll = jasmine.createSpy("getNextRoll").and.returnValue(20);
expect(rollCheckSingleDie(4, new RollOptions(), rollProvider)).toEqual(
new RollResult(0, RollResultStatus.CRITICAL_FAILURE, [20]),
);
});
}); });