mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-22 14:02:37 -05:00
Updating timer test for timeElapsed
This is a better name for it and now the value isn't negative...
This commit is contained in:
parent
92dab97b84
commit
1bda89ffbb
1 changed files with 7 additions and 5 deletions
|
@ -10,7 +10,7 @@ test('spec', function (t) {
|
|||
t.type(timer.startTime, 'number');
|
||||
t.type(timer.time, 'function');
|
||||
t.type(timer.start, 'function');
|
||||
t.type(timer.stop, 'function');
|
||||
t.type(timer.timeElapsed, 'function');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
@ -23,7 +23,7 @@ test('time', function (t) {
|
|||
t.end();
|
||||
});
|
||||
|
||||
test('start / stop', function (t) {
|
||||
test('start / timeElapsed', function (t) {
|
||||
var timer = new Timer();
|
||||
var delay = 100;
|
||||
var threshold = 1000 / 60; // 60 hz
|
||||
|
@ -31,10 +31,12 @@ test('start / stop', function (t) {
|
|||
// Start timer
|
||||
timer.start();
|
||||
|
||||
// Wait and stop timer
|
||||
// Wait and measure timer
|
||||
setTimeout(function () {
|
||||
var stop = timer.stop();
|
||||
t.ok(stop >= -(delay + threshold) && stop <= -(delay - threshold));
|
||||
var timeElapsed = timer.timeElapsed();
|
||||
t.ok(timeElapsed >= 0);
|
||||
t.ok(timeElapsed >= (delay - threshold) &&
|
||||
timeElapsed <= (delay + threshold));
|
||||
t.end();
|
||||
}, delay);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue