From 427149c9a4c4e0b389520d67199af01ad3c3f0c2 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Thu, 20 Jul 2017 13:13:30 -0400 Subject: Implement keepHigh --- __tests__/dice.test.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to '__tests__') diff --git a/__tests__/dice.test.js b/__tests__/dice.test.js index 1274b3d..1be0744 100644 --- a/__tests__/dice.test.js +++ b/__tests__/dice.test.js @@ -5,7 +5,8 @@ const { add, subtract, negative, - explode + explode, + keepHigh } = require('../src/dice.js') const defaultNumberRolls = 500 @@ -378,3 +379,30 @@ describe('exploding dice', () => { }) }) }) + +describe('keep', () => { + describe('1K2d20', () => { + const die = keepHigh(constant(1), d(constant(2), constant(20))) + + testDie(die, { + diceCount: 1, + average: { + average: 13.825 + }, + variance: { + variance: 22.104 + }, + bounds: { + low: 1, + high: 20, + expectLow: true, + expectHigh: true + } + }, 800) + }) + + describe('2K1d20', () => { + const die = keepHigh(constant(2), d(constant(1), constant(20))) + testDie(die, basicDieTestSpecs(1, 20)) + }) +}) -- cgit v1.2.3