diff --git a/lib/gather/controller.js b/lib/gather/controller.js index 03be11f..0bfe604 100644 --- a/lib/gather/controller.js +++ b/lib/gather/controller.js @@ -25,8 +25,8 @@ var Gather = require("./gather"); var gather = new Gather(); // ***** Generate Test Users ***** -// var helper = require("./helper"); -// helper.createTestUsers({ gather: gather }); +var helper = require("./helper"); +helper.createTestUsers({ gather: gather }); module.exports = function (namespace) { var refreshGather = function () { diff --git a/lib/gather/gather.js b/lib/gather/gather.js index 4222bd9..b483cbd 100644 --- a/lib/gather/gather.js +++ b/lib/gather/gather.js @@ -14,10 +14,15 @@ var Gatherer = require("./gatherer"); var StateMachine = require("javascript-state-machine"); -function Gather () { +function Gather (options) { if (!(this instanceof Gather)) { - return new Gather(); + return new Gather(options); } + + if (typeof options.onElectionTimeout === 'function') { + this.onElectionTimeout = options.onElectionTimeout; + } + this.TEAM_SIZE = 6; this.gatherers = []; this.ELECTION_INTERVAL = 10000; // 10 Seconds (temporarily) diff --git a/spec/gather.js b/spec/gather.js index 1d7f136..ead7555 100644 --- a/spec/gather.js +++ b/spec/gather.js @@ -45,6 +45,13 @@ describe("Gather Model:", function () { describe("Election Tmimeout", function () { it ("starts a timer and transitions to next state when timer runs out", function (done) { + gather = new Gather({ + onElectionTimeout: function () { + assert.equal(gather.current, "selection"); + assert.isNull(gather.electionStartTime); + done(); + } + }); gather.ELECTION_INTERVAL = 100; // 1 second assert.isNull(gather.electionStartTime); gatherers.forEach(function (gatherer) { @@ -52,11 +59,6 @@ describe("Gather Model:", function () { }); assert.equal(gather.current, "election"); assert.isNotNull(gather.electionStartTime); - setTimeout(function () { - assert.equal(gather.current, "selection"); - assert.isNull(gather.electionStartTime); - done(); - }, 200); }); });