diff --git a/ui/src/Components/Grid/AlertGrid/index.test.js b/ui/src/Components/Grid/AlertGrid/index.test.js index 60d3c36ac..fad39df8a 100644 --- a/ui/src/Components/Grid/AlertGrid/index.test.js +++ b/ui/src/Components/Grid/AlertGrid/index.test.js @@ -2,6 +2,8 @@ import React from "react"; import { shallow } from "enzyme"; +import { advanceBy, clear } from "jest-date-mock"; + import { MockAlert, MockAlertGroup } from "__mocks__/Alerts.js"; import { AlertStore } from "Stores/AlertStore"; import { Settings } from "Stores/Settings"; @@ -12,6 +14,10 @@ let alertStore; let settingsStore; let silenceFormStore; +beforeAll(() => { + jest.useFakeTimers(); +}); + beforeEach(() => { alertStore = new AlertStore([]); settingsStore = new Settings(); @@ -19,7 +25,10 @@ beforeEach(() => { }); afterEach(() => { + jest.clearAllTimers(); + jest.clearAllMocks(); jest.restoreAllMocks(); + clear(); }); const ShallowAlertGrid = () => { @@ -305,4 +314,12 @@ describe("", () => { "id2" ]); }); + + it("doesn't throw errors after FontFaceObserver timeout", () => { + MockGroupList(60, 5); + ShallowAlertGrid(); + // skip a minute to trigger FontFaceObserver timeout handler + advanceBy(60 * 1000); + jest.runOnlyPendingTimers(); + }); });