ds4/spec/support/ds4rolls.spec.ts

64 lines
2.7 KiB
TypeScript

import { rollCheckSingleDie, RollOptions, RollResult, RollResultStatus } from "../../src/module/rolls/roll-executor";
import { RollProvider } from "../../src/module/rolls/roll-provider";
describe("DS4 Rolls", () => {
it("Should do a proper single success roll.", () => {
const rollProvider: RollProvider = jasmine.createSpyObj("rollProvider", ["getNextRoll"]);
rollProvider.getNextRoll = jasmine.createSpy("getNextRoll").and.returnValue(4);
expect(rollCheckSingleDie(12, new RollOptions(), rollProvider)).toEqual(
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]),
);
});
});