Refactor card.ts substantially and test.

This commit is contained in:
Dermot Duffy
2023-10-02 16:30:05 -07:00
parent 4cf13b1645
commit bfdbe70d6c
92 changed files with 8404 additions and 2996 deletions
+18 -2
View File
@@ -30,6 +30,22 @@ describe('Timer', () => {
expect(handler).toBeCalled();
});
it('should not fire when stopped', () => {
const timer = new Timer();
const handler = vi.fn();
timer.start(10, handler);
expect(timer.isRunning()).toBeTruthy();
expect(handler).not.toBeCalled();
timer.stop();
vi.runOnlyPendingTimers();
expect(timer.isRunning()).toBeFalsy();
expect(handler).not.toBeCalled();
});
it('should fire repeatedly when started', () => {
const timer = new Timer();
const handler = vi.fn();
@@ -49,10 +65,10 @@ describe('Timer', () => {
expect(handler).toBeCalledTimes(2);
});
it('should not fire when stopped', () => {
it('should not fire repeatedly when stopped', () => {
const timer = new Timer();
const handler = vi.fn();
timer.start(10, handler);
timer.startRepeated(10, handler);
expect(timer.isRunning()).toBeTruthy();
expect(handler).not.toBeCalled();