add more tests

This commit is contained in:
gabrielburnworth 2018-08-27 14:03:29 -07:00
parent 73b37cc0b5
commit 167375ee5e
3 changed files with 37 additions and 2 deletions

View file

@ -61,6 +61,21 @@ describe("safeBooleanSetting", () => {
});
});
describe("deprecatedGetNum", () => {
it("gets number", () => {
const result = Session.deprecatedGetNum("success_log");
expect(result).toEqual(3);
});
});
describe("deprecatedSetNum", () => {
it("sets number", () => {
Session.deprecatedSetNum("success_log", 0);
expect(edit).toHaveBeenCalledWith(expect.any(Object), { success_log: 0 });
expect(save).toHaveBeenCalledWith(mockConfig.uuid);
});
});
describe("setBool", () => {
it("sets bool", () => {
Session.setBool("x_axis_inverted", false);

View file

@ -11,8 +11,12 @@ jest.mock("../zoom", () => {
import * as React from "react";
import { shallow, mount } from "enzyme";
import { GardenMapLegend, ZoomControls } from "../garden_map_legend";
import {
GardenMapLegend, ZoomControls, PointsSubMenu
} from "../garden_map_legend";
import { GardenMapLegendProps } from "../interfaces";
import { clickButton } from "../../../__test_support__/helpers";
import { history } from "../../../history";
describe("<GardenMapLegend />", () => {
const fakeProps = (): GardenMapLegendProps => ({
@ -36,6 +40,13 @@ describe("<GardenMapLegend />", () => {
const wrapper = mount(<GardenMapLegend {...fakeProps()} />);
["plants", "origin", "move"].map(string =>
expect(wrapper.text().toLowerCase()).toContain(string));
expect(wrapper.find("Popover").length).toEqual(1);
});
it("shows submenu", () => {
localStorage.setItem("FUTURE_FEATURES", "true");
const wrapper = mount(<GardenMapLegend {...fakeProps()} />);
expect(wrapper.find("Popover").length).toEqual(2);
});
});
@ -65,3 +76,12 @@ describe("<ZoomControls />", () => {
expectDisabledBtnCountToEqual(1);
});
});
describe("<PointsSubMenu />", () => {
it("navigates to point creator", () => {
const wrapper = mount(<PointsSubMenu />);
clickButton(wrapper, 0, "point creator");
expect(history.push).toHaveBeenCalledWith(
"/app/designer/plants/create_point");
});
});

View file

@ -48,7 +48,7 @@ export const ZoomControls = ({ zoom, getConfigValue }: {
</div>;
};
const PointsSubMenu = () =>
export const PointsSubMenu = () =>
<div>
<button className={"fb-button green"}
onClick={() => history.push("/app/designer/plants/create_point")}>