m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/__tests__/dice.test.js
diff options
context:
space:
mode:
Diffstat (limited to '__tests__/dice.test.js')
-rw-r--r--__tests__/dice.test.js45
1 files changed, 44 insertions, 1 deletions
diff --git a/__tests__/dice.test.js b/__tests__/dice.test.js
index d397d4c..6a9ba46 100644
--- a/__tests__/dice.test.js
+++ b/__tests__/dice.test.js
@@ -16,7 +16,8 @@ const {
againAbove,
againUnder,
thresholdHigh,
- thresholdLow
+ thresholdLow,
+ repeat
} = require('../src/dice.js')
const defaultNumberRolls = 500
@@ -692,3 +693,45 @@ describe('threshold', () => {
})
})
})
+
+describe('repeat', () => {
+ describe('1d6 x 2', () => {
+ const die = repeat(d(constant(1), constant(6)), constant(2))
+
+ testDie(die, {
+ diceCount: 2,
+ average: {
+ average: 7
+ },
+ variance: {
+ variance: 5.83
+ },
+ bounds: {
+ low: 2,
+ high: 12,
+ expectLow: true,
+ expectHigh: true
+ }
+ })
+ })
+
+ describe('1d6 x 1d4', () => {
+ const die = repeat(d(constant(1), constant(6)), d(constant(1), constant(4)))
+
+ testDie(die, {
+ variableDiceCount: {
+ min: 1,
+ max: 4
+ },
+ average: {
+ average: 8.75
+ },
+ bounds: {
+ low: 1,
+ high: 24,
+ expectLow: true,
+ expectHigh: false
+ }
+ })
+ })
+})