Skip to content

Commit

Permalink
Add first interval tests
Browse files Browse the repository at this point in the history
  • Loading branch information
blaumeise20 committed Jan 10, 2021
1 parent 7d0e90a commit d8d2d09
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,21 @@ describe('time start tests', () => {
expect(setTimeout).toHaveBeenCalledTimes(1);
expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), waitTime);
});

test('interval is not started when autostart is false', () => {
const to = new Interval(() => to.stop(), 1, false);
expect(setInterval).toHaveBeenCalledTimes(0);
});

test('interval is not started when autostart is not specified', () => {
const to = new Interval(() => to.stop(), 1);
expect(setInterval).toHaveBeenCalledTimes(0);
});

test('interval is started when autostart is true', () => {
const waitTime = 1000;
const to = new Interval(() => to.stop(), waitTime, true);
expect(setInterval).toHaveBeenCalledTimes(1);
expect(setInterval).toHaveBeenLastCalledWith(expect.any(Function), waitTime);
});
});

0 comments on commit d8d2d09

Please sign in to comment.