mirror of
https://github.com/prymitive/karma
synced 2026-05-07 03:26:52 +00:00
fix(ui): fixing tests that stopped working with rca 2.0
This commit is contained in:
@@ -2,6 +2,14 @@ import * as Sentry from "@sentry/browser";
|
||||
|
||||
import { SettingsElement, SetupSentry, ParseDefaultFilters } from "./AppBoot";
|
||||
|
||||
beforeAll(() => {
|
||||
// https://github.com/jamesmfriedman/rmwc/issues/103#issuecomment-360007979
|
||||
Object.defineProperty(window.HTMLElement.prototype, "dataset", {
|
||||
writable: true,
|
||||
value: {}
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
// reset sentry state before each mock, that's the only way to revert
|
||||
// Sentry.init() that I found
|
||||
|
||||
@@ -52,6 +52,7 @@ exports[`<Alert /> matches snapshot with showAlertmanagers=false showReceiver=fa
|
||||
role=\\"img\\"
|
||||
xmlns=\\"http://www.w3.org/2000/svg\\"
|
||||
viewbox=\\"0 0 320 512\\"
|
||||
style=\\"width: 0.8rem;\\"
|
||||
>
|
||||
<path fill=\\"currentColor\\"
|
||||
d=\\"M31.3 192h257.3c17.8 0 26.7 21.5 14.1 34.1L174.1 354.8c-7.8 7.8-20.5 7.8-28.3 0L17.2 226.1C4.6 213.5 13.5 192 31.3 192z\\"
|
||||
|
||||
@@ -22,7 +22,9 @@ describe("<UpgradeNeeded />", () => {
|
||||
});
|
||||
|
||||
it("calls window.location.reload after timer is done", () => {
|
||||
const reloadSpy = jest.spyOn(global.window.location, "reload");
|
||||
const reloadSpy = jest
|
||||
.spyOn(global.window.location, "reload")
|
||||
.mockImplementation(() => {});
|
||||
mount(<UpgradeNeeded newVersion="1.2.3" />);
|
||||
jest.runOnlyPendingTimers();
|
||||
expect(reloadSpy).toBeCalled();
|
||||
|
||||
@@ -30,8 +30,12 @@ const MountedFailingComponent = () => {
|
||||
|
||||
describe("<ErrorBoundary />", () => {
|
||||
it("matches snapshot", () => {
|
||||
const consoleSpy = jest
|
||||
.spyOn(console, "error")
|
||||
.mockImplementation(() => {});
|
||||
const tree = MountedFailingComponent();
|
||||
expect(toDiffableHtml(tree.html())).toMatchSnapshot();
|
||||
expect(consoleSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("componentDidCatch should catch an error from FailingComponent", () => {
|
||||
|
||||
@@ -5,13 +5,13 @@ import Adapter from "enzyme-adapter-react-16";
|
||||
Enzyme.configure({ adapter: new Adapter() });
|
||||
|
||||
// localStorage is used for Settings store
|
||||
require("jest-localstorage-mock");
|
||||
import("jest-localstorage-mock");
|
||||
|
||||
// favico.js needs canvas
|
||||
require("jest-canvas-mock");
|
||||
import("jest-canvas-mock");
|
||||
|
||||
// used to mock current time since we render moment.fromNow() in some places
|
||||
require("jest-date-mock");
|
||||
import("jest-date-mock");
|
||||
|
||||
// fetch is used in multiple places to interact with Go backend
|
||||
// or upstream Alertmanager API
|
||||
|
||||
Reference in New Issue
Block a user