Merge pull request #2492 from ericrosenbaum/test-clock-reset

Add a unit test for the clock being reset on runtime dispose
This commit is contained in:
Eric Rosenbaum 2020-06-25 13:31:39 -04:00 committed by GitHub
commit da68c4faf6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -250,3 +250,24 @@ test('Disposing the runtime emits an event', t => {
t.equal(disposed, true); t.equal(disposed, true);
t.end(); t.end();
}); });
test('Clock is reset on runtime dispose', t => {
const rt = new Runtime();
const c = rt.ioDevices.clock;
let simulatedTime = 0;
c._projectTimer = {
timeElapsed: () => simulatedTime,
start: () => {
simulatedTime = 0;
}
};
t.ok(c.projectTimer() === 0);
simulatedTime += 1000;
t.ok(c.projectTimer() === 1);
rt.dispose();
// When the runtime is disposed, the clock should be reset
t.ok(c.projectTimer() === 0);
t.end();
});