Farmbot-Web-App/frontend/farm_designer/plants/__tests__/plant_inventory_test.tsx

39 lines
1.3 KiB
TypeScript
Raw Normal View History

2017-09-14 03:17:24 -06:00
import * as React from "react";
2019-09-23 12:56:35 -06:00
import { RawPlants as Plants, PlantInventoryProps } from "../plant_inventory";
2019-03-05 11:59:22 -07:00
import { mount, shallow } from "enzyme";
2017-09-14 03:17:24 -06:00
import { fakePlant } from "../../../__test_support__/fake_state/resources";
describe("<PlantInventory />", () => {
2019-03-05 11:59:22 -07:00
const fakeProps = (): PlantInventoryProps => ({
plants: [fakePlant()],
dispatch: jest.fn(),
hoveredPlantListItem: undefined,
});
2017-09-14 03:17:24 -06:00
it("renders", () => {
2019-09-23 12:56:35 -06:00
const wrapper = mount(<Plants {...fakeProps()} />);
2018-04-20 22:50:48 -06:00
["Map",
"Plants",
"Events",
2018-04-20 22:50:48 -06:00
"Strawberry Plant",
2017-10-16 22:22:35 -06:00
"11 days old"
].map(string => expect(wrapper.text()).toContain(string));
2017-09-14 03:17:24 -06:00
expect(wrapper.find("input").props().placeholder)
.toEqual("Search your plants...");
});
2019-03-05 11:59:22 -07:00
it("has link to crops", () => {
2019-09-23 12:56:35 -06:00
const wrapper = mount(<Plants {...fakeProps()} />);
2019-03-05 11:59:22 -07:00
expect(wrapper.html()).toContain("fa-plus");
expect(wrapper.html()).toContain("/app/designer/plants/crop_search");
});
it("updates search term", () => {
2019-09-23 12:56:35 -06:00
const wrapper = shallow<Plants>(<Plants {...fakeProps()} />);
2019-03-05 11:59:22 -07:00
expect(wrapper.state().searchTerm).toEqual("");
wrapper.find("input").first().simulate("change",
{ currentTarget: { value: "mint" } });
expect(wrapper.state().searchTerm).toEqual("mint");
});
2017-09-14 03:17:24 -06:00
});