mirror of
https://github.com/prymitive/karma
synced 2026-05-05 03:16:51 +00:00
feat(tests): add history dropdown visibility test
This commit is contained in:
14
ui/__mocks__/popper.js.js
Normal file
14
ui/__mocks__/popper.js.js
Normal file
@@ -0,0 +1,14 @@
|
||||
// https://github.com/FezVrasta/popper.js/issues/478#issuecomment-341506071
|
||||
|
||||
import PopperJs from "popper.js";
|
||||
|
||||
export default class Popper {
|
||||
static placements = PopperJs.placements;
|
||||
|
||||
constructor() {
|
||||
return {
|
||||
destroy: () => {},
|
||||
scheduleUpdate: () => {}
|
||||
};
|
||||
}
|
||||
}
|
||||
6
ui/__mocks__/react-onclickoutside.js
vendored
Normal file
6
ui/__mocks__/react-onclickoutside.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
// mock react-onclickoutside so we bypass it due to:
|
||||
// TypeError: Cannot read property 'isReactComponent' of undefined
|
||||
|
||||
export default function onClickOutsideHOC(WrappedComponent, config) {
|
||||
return WrappedComponent;
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
import React from "react";
|
||||
import renderer from "react-test-renderer";
|
||||
|
||||
import { mount } from "enzyme";
|
||||
|
||||
import { AlertStore, NewUnappliedFilter } from "Stores/AlertStore";
|
||||
import { Settings } from "Stores/Settings";
|
||||
import { History, ReduceFilter } from "./History";
|
||||
@@ -37,6 +39,19 @@ describe("<History />", () => {
|
||||
);
|
||||
});
|
||||
|
||||
// Due to https://github.com/FezVrasta/popper.js/issues/478 we can't test
|
||||
// rendered dropdown content, only the fact that toggle value is updated
|
||||
it("renders dropdown button when menu is visible", () => {
|
||||
const tree = mount(
|
||||
<History alertStore={alertStore} settingsStore={settingsStore} />
|
||||
);
|
||||
const toggle = tree.find("button.components-navbar-history");
|
||||
|
||||
expect(tree.instance().collapse.value).toBe(true);
|
||||
toggle.simulate("click");
|
||||
expect(tree.instance().collapse.value).toBe(false);
|
||||
});
|
||||
|
||||
it("saves only applied filters to history", () => {
|
||||
alertStore.filters.values = [
|
||||
AppliedFilter("foo", "=", "bar"),
|
||||
|
||||
Reference in New Issue
Block a user