forked from my8bird/nodejs-secure-random
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_random.js
More file actions
32 lines (28 loc) · 1.02 KB
/
test_random.js
File metadata and controls
32 lines (28 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var random = require('./random'),
should = require('should');
describe('Random', function(){
describe('Using Min and Max', function() {
var iteration = 3000;
it('should return a random number if no range is supplied', function(done) {
var i, j=0;
for (i=0; i < iteration; i++) {
random.getRandomInt(function(err, value) {
if (err) {throw err;}
value.should.be.a('number');
if (++j === iteration) {done();}
});
}
});
it('should return a random number greater then min', function(done){
var i, j=0;
for (i=0; i < iteration; i++) {
random.getRandomInt(20, 100, function(err, value) {
if (err) {throw err;}
value.should.be.a('number');
value.should.be.within(20, 100);
if (++j === iteration) {done();}
});
}
})
})
})