From 056fe630bf522301ce48a1a615ed290930bbe8d9 Mon Sep 17 00:00:00 2001 From: Marak Date: Sun, 14 Oct 2018 23:28:11 -0400 Subject: [PATCH] [test] Increasing coverage for Mersenne Twister * Covers internal argument validation * This validation is already tested upstream --- test/random.unit.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/random.unit.js b/test/random.unit.js index e3befcdce..fe46cbf85 100644 --- a/test/random.unit.js +++ b/test/random.unit.js @@ -3,6 +3,7 @@ if (typeof module !== 'undefined') { var sinon = require('sinon'); var _ = require('lodash'); var faker = require('../index'); + var mersenne = require('../vendor/mersenne'); } @@ -279,4 +280,25 @@ describe("random.js", function () { assert.ok(hex.match(/^(0x)[0-9a-f]+$/i)); }) }) + + describe("mersenne twister", function() { + it("returns a random number without given min / max arguments", function() { + var max = 10; + var randomNumber = mersenne.rand(); + assert.ok(typeof randomNumber === 'number'); + }); + + it("throws an error when attempting to seed() a non-integer", function() { + assert.throws(function () { + mersenne.seed('abc'); + }, Error); + }); + + it("throws an error when attempting to seed() a non-integer", function() { + assert.throws(function () { + mersenne.seed_array('abc'); + }, Error); + }); + }) + });