Test that clock is reset on runtime dispose

This commit is contained in:
Eric Rosenbaum 2020-06-22 11:56:10 -04:00
parent 540d9c676c
commit 60aeebf668

View file

@ -35,3 +35,24 @@ test('cycle', t => {
rt._step();
t.ok(c.projectTimer() > 0);
});
test('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();
});