m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/__tests__
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-08-22 14:49:11 -0400
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-08-22 14:49:11 -0400
commita31c3a1fd44a37cf0fcfff8c1cc52792565247b3 (patch)
treedf238e311a87344e52faf587c6f2165cc4487e4b /__tests__
parent56d36c9129292cd0dd0b5e79eea14d79a4219a94 (diff)
Implement bonusAdd
Diffstat (limited to '__tests__')
-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
+ }
+ })
+ })
+})