Permalink
Browse files

Fixing unit test and method

  • Loading branch information...
1 parent 976ce19 commit 97bffaa5430f589e9bedac03ab6fc05b81408ae6 @monsur committed Jan 16, 2016
Showing with 8 additions and 7 deletions.
  1. +4 −3 src/server/event.js
  2. +4 −4 test/server/event.test.js
View
@@ -17,9 +17,10 @@ var defaultOptions = {
};
var getRandomTimeout = function(timeout) {
- var min = parseInt(timeout * 0.2);
- var max = parseInt(timeout * 0.8);
- return (Math.floor(Math.random() * max) + min) * 1000;
+ timeout = timeout * 1000;
+ var min = timeout * 0.2;
+ var max = timeout * 0.8;
+ return Math.floor(Math.random() * (max - min)) + min;
};
/**
@@ -239,8 +239,8 @@ describe('subscribe internal', function() {
// TODO: Validate that renew is actually called.
};
Event.setTimeout = function(callback, timeout) {
- assert(timeout < 7200);
- assert(timeout > 1800);
+ assert(timeout < 9600, "Timeout: " + timeout);
+ assert(timeout > 2400, "Timeout: " + timeout);
callback();
};
event.subscribeInternal({}, function(error, data) {
@@ -259,8 +259,8 @@ describe('subscribe internal', function() {
}});
};
Event.setTimeout = function(callback, timeout) {
- assert(timeout < 25920000);
- assert(timeout > 6480000);
+ assert(timeout < 34560000, "Timeout: " + timeout);
+ assert(timeout > 8640000, "Timeout: " + timeout);
};
event.subscribeInternal({}, function(error, data) {
assert.equal(error, null);

0 comments on commit 97bffaa

Please sign in to comment.