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.js218
1 files changed, 109 insertions, 109 deletions
diff --git a/__tests__/dice.test.js b/__tests__/dice.test.js
index 6ff86e7..15941cb 100644
--- a/__tests__/dice.test.js
+++ b/__tests__/dice.test.js
@@ -4,12 +4,12 @@ const {
d,
add,
subtract,
+ bonusAdd,
+ bonusSubtract,
negative,
explode,
keepHigh,
- keepLow,
- bonusAdd,
- bonusSubtract
+ keepLow
} = require('../src/dice.js')
const defaultNumberRolls = 500
@@ -293,12 +293,6 @@ describe('add', () => {
])
})
-describe('negative', () => {
- describeBasicDie(1, 6, defaultNumberRolls, true)
- describeBasicDie(0, 6, defaultNumberRolls, true)
- describeBasicDie(2, 8, defaultNumberRolls, true)
-})
-
describe('subtract', () => {
describeCompoundDice([
{ number: 1, sides: 6 },
@@ -317,6 +311,112 @@ describe('subtract', () => {
})
})
+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
+ }
+ })
+ })
+})
+
+describe('bonusSubtract', () => {
+ describe('1d20-3', () => {
+ const die = bonusSubtract(d(constant(1), constant(20)), constant(3))
+ testDie(die, {
+ diceCount: 1,
+ average: {
+ average: 7.5
+ },
+ variance: {
+ variance: 33.25
+ },
+ bounds: {
+ low: -2,
+ high: 17,
+ expectLow: true,
+ expectHigh: true
+ }
+ })
+ })
+
+ describe('3d4-1', () => {
+ const die = bonusSubtract(d(constant(3), constant(4)), constant(1))
+ testDie(die, {
+ diceCount: 3,
+ average: {
+ average: 4.5
+ },
+ variance: {
+ variance: 3.75
+ },
+ bounds: {
+ low: 0,
+ high: 9,
+ expectLow: true,
+ expectHigh: true
+ }
+ })
+ })
+})
+
+describe('negative', () => {
+ describeBasicDie(1, 6, defaultNumberRolls, true)
+ describeBasicDie(0, 6, defaultNumberRolls, true)
+ describeBasicDie(2, 8, defaultNumberRolls, true)
+})
+
describe('compound dice', () => {
describe('(1d4)d(1d6)', () => {
const die = d(d(constant(1), constant(4)), d(constant(1), constant(6)))
@@ -434,103 +534,3 @@ 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
- }
- })
- })
-})
-
-describe('bonusSubtract', () => {
- describe('1d20-3', () => {
- const die = bonusSubtract(d(constant(1), constant(20)), constant(3))
- testDie(die, {
- diceCount: 1,
- average: {
- average: 7.5
- },
- variance: {
- variance: 33.25
- },
- bounds: {
- low: -2,
- high: 17,
- expectLow: true,
- expectHigh: true
- }
- })
- })
-
- describe('3d4-1', () => {
- const die = bonusSubtract(d(constant(3), constant(4)), constant(1))
- testDie(die, {
- diceCount: 3,
- average: {
- average: 4.5
- },
- variance: {
- variance: 3.75
- },
- bounds: {
- low: 0,
- high: 9,
- expectLow: true,
- expectHigh: true
- }
- })
- })
-})