Updating timer test for timeElapsed

This is a better name for it and now the value isn't negative...
This commit is contained in:
Tim Mickel 2016-04-26 17:03:22 -04:00
parent 92dab97b84
commit 1bda89ffbb

View file

@ -10,7 +10,7 @@ test('spec', function (t) {
t.type(timer.startTime, 'number'); t.type(timer.startTime, 'number');
t.type(timer.time, 'function'); t.type(timer.time, 'function');
t.type(timer.start, 'function'); t.type(timer.start, 'function');
t.type(timer.stop, 'function'); t.type(timer.timeElapsed, 'function');
t.end(); t.end();
}); });
@ -23,7 +23,7 @@ test('time', function (t) {
t.end(); t.end();
}); });
test('start / stop', function (t) { test('start / timeElapsed', function (t) {
var timer = new Timer(); var timer = new Timer();
var delay = 100; var delay = 100;
var threshold = 1000 / 60; // 60 hz var threshold = 1000 / 60; // 60 hz
@ -31,10 +31,12 @@ test('start / stop', function (t) {
// Start timer // Start timer
timer.start(); timer.start();
// Wait and stop timer // Wait and measure timer
setTimeout(function () { setTimeout(function () {
var stop = timer.stop(); var timeElapsed = timer.timeElapsed();
t.ok(stop >= -(delay + threshold) && stop <= -(delay - threshold)); t.ok(timeElapsed >= 0);
t.ok(timeElapsed >= (delay - threshold) &&
timeElapsed <= (delay + threshold));
t.end(); t.end();
}, delay); }, delay);
}); });