diff --git a/.eslintrc.json b/.eslintrc.json index 60ea78f..0bea4d3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -13,5 +13,8 @@ "quotes": ["error", "double"], "indent": ["error", 4], "semi": "error" + }, + "env": { + "jest/globals": true } } diff --git a/index.test.js b/index.test.js index 5107bcd..404f763 100644 --- a/index.test.js +++ b/index.test.js @@ -1,17 +1,17 @@ const { Timeout, Interval } = require("."); -require('jest'); +require("jest"); beforeEach(() => { jest.useFakeTimers(); }); -describe('state tests', () => { - test('state is set to 0 after creation of timer', () => { +describe("state tests", () => { + test("state is set to 0 after creation of timer", () => { const to = new Timeout(() => { }, 0); expect(to.state).toBe(0); }); - test('state is set to 1 when timer has been started', () => { + test("state is set to 1 when timer has been started", () => { const waitTime = 1000; const callback = jest.fn(); const to = new Timeout(callback, waitTime); @@ -19,7 +19,7 @@ describe('state tests', () => { expect(to.state).toBe(1); }); - test('state is set to 3 and callback is called after timer is completed', () => { + test("state is set to 3 and callback is called after timer is completed", () => { const waitTime = 1000; const callback = jest.fn(); const to = new Timeout(callback, waitTime); @@ -32,35 +32,35 @@ describe('state tests', () => { }); }); -describe('time start tests', () => { - test('timeout is not started when autostart is false', () => { +describe("time start tests", () => { + test("timeout is not started when autostart is false", () => { const to = new Timeout(() => { }, 0, false); expect(setTimeout).toHaveBeenCalledTimes(0); }); - test('timeout is not started when autostart is not specified', () => { + test("timeout is not started when autostart is not specified", () => { const to = new Timeout(() => { }, 0); expect(setTimeout).toHaveBeenCalledTimes(0); }); - test('timeout is started when autostart is true', () => { + test("timeout is started when autostart is true", () => { const waitTime = 1000; const to = new Timeout(() => { }, waitTime, true); expect(setTimeout).toHaveBeenCalledTimes(1); expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), waitTime); }); - test('interval is not started when autostart is false', () => { + 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', () => { + 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', () => { + test("interval is started when autostart is true", () => { const waitTime = 1000; const to = new Interval(() => to.stop(), waitTime, true); expect(setInterval).toHaveBeenCalledTimes(1);