mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-22 22:12:28 -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.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);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue