m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--__tests__/dice.test.js5
-rw-r--r--src/dice.js2
2 files changed, 4 insertions, 3 deletions
diff --git a/__tests__/dice.test.js b/__tests__/dice.test.js
index 5d3fac1..9f3106e 100644
--- a/__tests__/dice.test.js
+++ b/__tests__/dice.test.js
@@ -40,7 +40,7 @@ expect.extend({
toAllBe(received, expected) {
const pass = received.reduce((allOk, value) => {
return allOk && value === expected
- })
+ }, true)
return {
pass,
@@ -74,7 +74,7 @@ const rollForTest = (die, numberRolls) => {
for (let i = 0; i < numberRolls; i++) {
let rolled = pool(die)
pools.push(rolled)
- rolls.push(rolled.reduce(plus))
+ rolls.push(rolled.reduce(plus, 0))
}
return { pools, rolls }
@@ -263,6 +263,7 @@ describe('constant', () => {
describe('basic dice', () => {
describeBasicDie(1, 6)
+ describeBasicDie(0, 6)
describeBasicDie(2, 8, 500)
describeBasicDie(20, 1)
})
diff --git a/src/dice.js b/src/dice.js
index 5edc892..1587eef 100644
--- a/src/dice.js
+++ b/src/dice.js
@@ -5,7 +5,7 @@ const pool = (die) => {
}
const roll = (die) => {
- return pool(die).reduce((a, b) => (a + b))
+ return pool(die).reduce((a, b) => (a + b), 0)
}
const d = (number, sides) => {