m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/__tests__
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-07-15 11:11:16 -0400
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-07-15 11:12:44 -0400
commit4912f2504246aba243001052d39c1e1a03b7d16c (patch)
treefa89af2b627daf411a470685bdbc5b4cd302a9d9 /__tests__
parent08ac17361566291d3e5415599d6f239a2fa90c7f (diff)
Assign allowed error value to test
Diffstat (limited to '__tests__')
-rw-r--r--__tests__/dice.test.js25
1 files changed, 17 insertions, 8 deletions
diff --git a/__tests__/dice.test.js b/__tests__/dice.test.js
index 83b8a9d..5d3fac1 100644
--- a/__tests__/dice.test.js
+++ b/__tests__/dice.test.js
@@ -203,13 +203,16 @@ const getDieString = diceSpecs => (
), '')
)
-const describeCompoundDice = (diceSpecs, numberRolls = defaultNumberRolls) => {
- const dieString = getDieString(diceSpecs)
- const die = diceSpecs.slice(1).reduce((die, spec) => {
+const combineDiceSpecs = diceSpecs => (
+ diceSpecs.slice(1).reduce((die, spec) => {
const combinator = spec.negative ? subtract : add
return combinator(die, d(constant(spec.number), constant(spec.sides)))
}, d(constant(diceSpecs[0].number), constant(diceSpecs[0].sides)))
+)
+const describeCompoundDice = (diceSpecs, numberRolls = defaultNumberRolls) => {
+ const dieString = getDieString(diceSpecs)
+ const die = combineDiceSpecs(diceSpecs)
describe(dieString, () => testDie(die, combinedDiceTestSpecs(diceSpecs),
numberRolls))
}
@@ -278,11 +281,17 @@ describe('subtract', () => {
{ number: 1, sides: 6 },
{ number: 1, sides: 4, negative: true }
])
- describeCompoundDice([
- { number: 3, sides: 6 },
- { number: 2, sides: 8, negative: true },
- { number: 1, sides: 1, negative: true }
- ], defaultNumberRolls, { varianceError: 1 })
+ describe('3d6 - 2d8 - 1d1', () => {
+ const diceSpecs = [
+ { number: 3, sides: 6 },
+ { number: 2, sides: 8, negative: true },
+ { number: 1, sides: 1, negative: true }
+ ]
+ const die = combineDiceSpecs(diceSpecs)
+ const testSpecs = combinedDiceTestSpecs(diceSpecs)
+ testSpecs.average.error = 1
+ describe('3d6 - 2d8 - 1d1', () => testDie(die, testSpecs, 700))
+ })
})
describe('compound dice', () => {