Skip to content

Commit

Permalink
Add test suite #44;
Browse files Browse the repository at this point in the history
Add unit test to calculate_bonus #38;
  • Loading branch information
eupolemo committed Feb 21, 2022
1 parent 89afa89 commit 8746012
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions dice-roller.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,35 @@ function calculate_bonus({ rises, bonus } = roll) {
bonus += rises * 2;
return bonus;
}

Hooks.on("quenchReady", (quench) => {
quench.registerBatch(
"l5r4d.parser.bonus",
(context) => {
const { describe, it, assert } = context;

describe("Calculate Bonus", function () {
it("Rises: 0 and Bonus: 0 should return 0", function () {
let bonus = calculate_bonus({rises: 0, bonus: 0});
assert.ok(bonus === 0);
});

it("Rises: 5 and Bonus: 0 should return 10", function () {
let bonus = calculate_bonus({rises: 5, bonus: 0});
assert.ok(bonus === 10);
});

it("Rises: 0 and Bonus: 1 should return 1", function () {
let bonus = calculate_bonus({rises: 0, bonus: 1});
assert.ok(bonus === 1);
});

it("Rises: 1 and Bonus: 1 should return 3", function () {
let bonus = calculate_bonus({rises: 1, bonus: 1});
assert.ok(bonus === 3);
});
});
},
{ displayName: "L5R4Ed dice Roller: Tests suite" },
);
});

0 comments on commit 8746012

Please sign in to comment.