mirror of
https://github.com/dmuth/diceware.git
synced 2024-11-21 16:36:28 -05:00
First tests in Mocha--now testing getRandomValue().
This commit is contained in:
parent
8d79feba2a
commit
3f1661281c
1 changed files with 56 additions and 0 deletions
56
tests/test.js
Normal file
56
tests/test.js
Normal file
|
@ -0,0 +1,56 @@
|
|||
|
||||
var assert = require('assert');
|
||||
var should = require('should');
|
||||
|
||||
var Promise = require("bluebird");
|
||||
|
||||
var diceware = require("../src/lib.js")
|
||||
|
||||
|
||||
|
||||
describe("Diceware", function() {
|
||||
describe("getRandomValue()", function(done) {
|
||||
|
||||
it("Should pass", function(done) {
|
||||
|
||||
Promise.try(function() {
|
||||
return(diceware.getRandomValue(-1));
|
||||
|
||||
}).catch(function(err) {
|
||||
err.should.match(/can't be less or equal to zero/);
|
||||
return(diceware.getRandomValue(0));
|
||||
|
||||
}).catch(function(err) {
|
||||
err.should.match(/can't be less or equal to zero/);
|
||||
return(diceware.getRandomValue(1));
|
||||
|
||||
}).then(function(num) {
|
||||
num.should.be.aboveOrEqual(0);
|
||||
num.should.be.lessThanOrEqual(1);
|
||||
return(diceware.getRandomValue(999));
|
||||
|
||||
}).then(function(num) {
|
||||
num.should.be.aboveOrEqual(0);
|
||||
num.should.be.lessThanOrEqual(999);
|
||||
done();
|
||||
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
TEST/TODO: Things to refactor:
|
||||
X Diceware.getRandomValue
|
||||
- Diceware.getBase6
|
||||
- Diceware.convertBase6ToDice
|
||||
- Diceware.getNumValuesFromNumDice
|
||||
- Diceware.rollDice(1).roll.length
|
||||
*/
|
||||
|
Loading…
Reference in a new issue