m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/__tests__/dice.test.js
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-09-11 15:47:50 -0400
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-09-11 15:47:50 -0400
commit9368b1c33db290d7c80c93db5c867cdb7fcaf14d (patch)
treec6170c157985624b373a13bb540bd4070321c18c /__tests__/dice.test.js
parentda6582f328c17e1842a4632d88e06d851e7c4b5f (diff)
Implement collecting
Diffstat (limited to '__tests__/dice.test.js')
-rw-r--r--__tests__/dice.test.js43
1 files changed, 42 insertions, 1 deletions
diff --git a/__tests__/dice.test.js b/__tests__/dice.test.js
index 9c03a48..56572d2 100644
--- a/__tests__/dice.test.js
+++ b/__tests__/dice.test.js
@@ -19,7 +19,8 @@ const {
againUnder,
thresholdHigh,
thresholdLow,
- repeat
+ repeat,
+ collect
} = require('../src/dice.js')
const defaultNumberRolls = 500
@@ -817,3 +818,43 @@ describe('repeat', () => {
})
})
})
+
+describe('collect', () => {
+ describe('[2d6]', () => {
+ const die = collect(d(constant(2), constant(6)))
+
+ testDie(die, {
+ diceCount: 1,
+ average: {
+ average: 7
+ },
+ variance: {
+ variance: 5.83
+ },
+ bounds: {
+ low: 2,
+ high: 12,
+ expectLow: true,
+ expectHigh: true
+ }
+ })
+ })
+
+ describe('[1d6 x 1d4]', () => {
+ const die =
+ collect(repeat(d(constant(1), constant(6)), d(constant(1), constant(4))))
+
+ testDie(die, {
+ diceCount: 1,
+ average: {
+ average: 8.75
+ },
+ bounds: {
+ low: 1,
+ high: 24,
+ expectLow: true,
+ expectHigh: false
+ }
+ })
+ })
+})