Merge pull request #613 from prymitive/fix-coverage

fix(tests): add missing test coverage for FontFaceObserver timeouts
This commit is contained in:
Łukasz Mierzwa
2019-04-11 23:05:48 +01:00
committed by GitHub

View File

@@ -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("<AlertGrid />", () => {
"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();
});
});