Now testing getBase6()

This commit is contained in:
Douglas Muth 2017-11-09 21:26:24 -05:00
parent 3f1661281c
commit 544f504bd3

View file

@ -7,9 +7,9 @@ var Promise = require("bluebird");
var diceware = require("../src/lib.js") var diceware = require("../src/lib.js")
describe("Diceware", function() { describe("Diceware", function() {
describe("getRandomValue()", function(done) {
describe("getRandomValue()", function() {
it("Should pass", function(done) { it("Should pass", function(done) {
@ -42,13 +42,44 @@ describe("Diceware", function() {
}); });
}); });
describe("getBase6()", function() {
it("Better pass", function() {
diceware.getBase6(0, 1).should.containDeepOrdered([0]);
diceware.getBase6(1, 1).should.containDeepOrdered([1]);
diceware.getBase6(5, 1).should.containDeepOrdered([5]);
diceware.getBase6(6, 2).should.containDeepOrdered([1, 0]);
diceware.getBase6(12, 2).should.containDeepOrdered([2, 0]);
diceware.getBase6(35, 2).should.containDeepOrdered([5, 5]);
diceware.getBase6(36, 3).should.containDeepOrdered([1, 0, 0]);
diceware.getBase6(180, 3).should.containDeepOrdered([5, 0, 0]);
diceware.getBase6(215, 3).should.containDeepOrdered([5, 5, 5]);
diceware.getBase6(216, 4).should.containDeepOrdered([1, 0, 0, 0]);
diceware.getBase6(1080, 4).should.containDeepOrdered([5, 0, 0, 0]);
diceware.getBase6(1295, 4).should.containDeepOrdered([5, 5, 5, 5]);
diceware.getBase6(7775, 5).should.containDeepOrdered([5, 5, 5, 5, 5]);
diceware.getBase6(46655, 6).should.containDeepOrdered([5, 5, 5, 5, 5, 5]);
diceware.getBase6(279935, 7).should.containDeepOrdered([5, 5, 5, 5, 5, 5, 5]);
diceware.getBase6(1679615, 8).should.containDeepOrdered([5, 5, 5, 5, 5, 5, 5, 5]);
should.throws(function() { diceware.getBase6(6, 1) }, /Value too large/);
should.throws(function() { diceware.getBase6(36, 2) }, /Value too large/);
should.throws(function() { diceware.getBase6(216, 3) }, /Value too large/);
should.throws(function() { diceware.getBase6(-1, 1) }, /Value cannot be negative/);
});
});
}); });
/* /*
TEST/TODO: Things to refactor: TEST/TODO: Things to refactor:
X Diceware.getRandomValue X Diceware.getRandomValue
- Diceware.getBase6 X Diceware.getBase6
- Diceware.convertBase6ToDice - Diceware.convertBase6ToDice
- Diceware.getNumValuesFromNumDice - Diceware.getNumValuesFromNumDice
- Diceware.rollDice(1).roll.length - Diceware.rollDice(1).roll.length