m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/__tests__
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-07-11 12:18:54 -0400
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-07-11 12:19:07 -0400
commitf07c5096999bf1a65d3082f8de42d3499b43e532 (patch)
tree05c95fc655a08b773e2bdb8532e7c57c1bf52e31 /__tests__
parent69b48d1a9c4e97d5f71230c75b3cfe6d8453558f (diff)
Test compound dice
Diffstat (limited to '__tests__')
-rw-r--r--__tests__/dice.test.js31
1 files changed, 30 insertions, 1 deletions
diff --git a/__tests__/dice.test.js b/__tests__/dice.test.js
index 04b1c84..fa2d2dc 100644
--- a/__tests__/dice.test.js
+++ b/__tests__/dice.test.js
@@ -89,6 +89,13 @@ const testDie = (die, testSpecs, numberRolls = defaultNumberRolls) => {
})
}
+ if ('variableDiceCount' in testSpecs) {
+ const {min, max} = testSpecs.variableDiceCount
+ it(`rolls between ${min} and ${max} dice`, () => {
+ expect(pools.map((pool) => (pool.length))).toBeBetween(min, max)
+ })
+ }
+
if ('average' in testSpecs) {
let { average, error } = testSpecs.average
@@ -275,5 +282,27 @@ describe('subtract', () => {
{ number: 3, sides: 6 },
{ number: 2, sides: 8, negative: true },
{ number: 1, sides: 1, negative: true }
- ])
+ ], defaultNumberRolls, { varianceError: 1 })
+})
+
+describe('compound dice', () => {
+ describe('(1d4)d(1d6)', () => {
+ const die = d(d(constant(1), constant(4)), d(constant(1), constant(6)))
+ const testSpec = {
+ variableDiceCount: {
+ min: 1,
+ max: 4,
+ },
+ average: {
+ average: 5.625
+ },
+ bounds: {
+ low: 1,
+ high: 24,
+ expectLow: true
+ }
+ }
+
+ testDie(die, testSpec)
+ })
})