refactor: improve testing setup
This commit is contained in:
parent
0c8f1e8bda
commit
de060b381e
8 changed files with 48 additions and 30 deletions
|
@ -5,39 +5,21 @@
|
|||
|
||||
import evaluateCheck from "../../src/rolls/check-evaluation";
|
||||
|
||||
class StubGame {
|
||||
constructor() {
|
||||
this.i18n = {
|
||||
localize: (key: string) => key,
|
||||
};
|
||||
}
|
||||
i18n: {
|
||||
localize: (key: string) => string;
|
||||
};
|
||||
}
|
||||
|
||||
const game = new StubGame();
|
||||
|
||||
Object.defineProperties(globalThis, {
|
||||
game: { value: game },
|
||||
Game: { value: StubGame },
|
||||
});
|
||||
|
||||
describe("evaluateCheck with no dice", () => {
|
||||
it("should throw an error.", () => {
|
||||
expect(() => evaluateCheck([], 10)).toThrow("DS4.ErrorInvalidNumberOfDice");
|
||||
expect(() => evaluateCheck([], 10)).toThrow("Invalid number of dice.");
|
||||
});
|
||||
});
|
||||
|
||||
describe("evaluateCheck with more dice than required by the checkTargetNumber", () => {
|
||||
it("should throw an error.", () => {
|
||||
expect(() => evaluateCheck([10, 10], 10)).toThrow("DS4.ErrorInvalidNumberOfDice");
|
||||
expect(() => evaluateCheck([10, 10], 10)).toThrow("Invalid number of dice.");
|
||||
});
|
||||
});
|
||||
|
||||
describe("evaluateCheck with less dice than required by the checkTargetNumber", () => {
|
||||
it("should throw an error.", () => {
|
||||
expect(() => evaluateCheck([10], 21)).toThrow("DS4.ErrorInvalidNumberOfDice");
|
||||
expect(() => evaluateCheck([10], 21)).toThrow("Invalid number of dice.");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue