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.js63
1 files changed, 62 insertions, 1 deletions
diff --git a/__tests__/dice.test.js b/__tests__/dice.test.js
index 1be0744..6fb48a2 100644
--- a/__tests__/dice.test.js
+++ b/__tests__/dice.test.js
@@ -6,7 +6,8 @@ const {
subtract,
negative,
explode,
- keepHigh
+ keepHigh,
+ bonusAdd
} = require('../src/dice.js')
const defaultNumberRolls = 500
@@ -406,3 +407,63 @@ describe('keep', () => {
testDie(die, basicDieTestSpecs(1, 20))
})
})
+
+describe('bonusAdd', () => {
+ describe('1d20+3', () => {
+ const die = bonusAdd(d(constant(1), constant(20)), constant(3))
+ testDie(die, {
+ diceCount: 1,
+ average: {
+ average: 13.5
+ },
+ variance: {
+ variance: 33.25
+ },
+ bounds: {
+ low: 4,
+ high: 23,
+ expectLow: true,
+ expectHigh: true
+ }
+ })
+ })
+
+ describe('3d4+1', () => {
+ const die = bonusAdd(d(constant(3), constant(4)), constant(1))
+ testDie(die, {
+ diceCount: 3,
+ average: {
+ average: 10.5
+ },
+ variance: {
+ variance: 3.75
+ },
+ bounds: {
+ low: 6,
+ high: 15,
+ expectLow: true,
+ expectHigh: true
+ }
+ })
+ })
+
+ describe('2d6+1d6', () => {
+ const die = bonusAdd(d(constant(2), constant(6)),
+ d(constant(1), constant(6)))
+ testDie(die, {
+ diceCount: 2,
+ average: {
+ average: 14
+ },
+ variance: {
+ variance: 11.67
+ },
+ bounds: {
+ low: 4,
+ high: 24,
+ expectLow: false,
+ expectHigh: false
+ }
+ })
+ })
+})