mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-28 22:30:40 -04:00
Add basic test coverage for clock module.
This commit is contained in:
parent
84bd42d734
commit
7e9745ce3f
1 changed files with 34 additions and 0 deletions
34
test/unit/io_clock.js
Normal file
34
test/unit/io_clock.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
var test = require('tap').test;
|
||||
var Clock = require('../../src/io/clock');
|
||||
var Runtime = require('../../src/engine/runtime');
|
||||
|
||||
test('spec', function (t) {
|
||||
var rt = new Runtime();
|
||||
var c = new Clock(rt);
|
||||
|
||||
t.type(Clock, 'function');
|
||||
t.type(c, 'object');
|
||||
t.type(c.projectTimer, 'function');
|
||||
t.type(c.pause, 'function');
|
||||
t.type(c.resume, 'function');
|
||||
t.type(c.resetProjectTimer, 'function');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cycle', function (t) {
|
||||
var rt = new Runtime();
|
||||
var c = new Clock(rt);
|
||||
|
||||
t.strictEqual(c.projectTimer(), 0);
|
||||
setTimeout(function () {
|
||||
c.resetProjectTimer();
|
||||
setTimeout(function () {
|
||||
t.ok(c.projectTimer() > 0);
|
||||
c.pause();
|
||||
t.ok(c.projectTimer() > 0);
|
||||
c.resume();
|
||||
t.ok(c.projectTimer() > 0);
|
||||
t.end();
|
||||
}, 100);
|
||||
}, 100);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue