mapStateToProps() test
parent
b5a8d53b02
commit
1a9c7f3508
|
@ -16,13 +16,14 @@ jest.mock("../../point_groups/actions", () => ({ createGroup: jest.fn() }));
|
|||
import * as React from "react";
|
||||
import { mount } from "enzyme";
|
||||
import {
|
||||
RawSelectPlants as SelectPlants, SelectPlantsProps
|
||||
RawSelectPlants as SelectPlants, SelectPlantsProps, mapStateToProps
|
||||
} from "../select_plants";
|
||||
import { fakePlant } from "../../../__test_support__/fake_state/resources";
|
||||
import { Actions } from "../../../constants";
|
||||
import { clickButton } from "../../../__test_support__/helpers";
|
||||
import { destroy } from "../../../api/crud";
|
||||
import { createGroup } from "../../point_groups/actions";
|
||||
import { fakeState } from "../../../__test_support__/fake_state";
|
||||
|
||||
describe("<SelectPlants />", () => {
|
||||
beforeEach(function () {
|
||||
|
@ -123,3 +124,14 @@ describe("<SelectPlants />", () => {
|
|||
expect(createGroup).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("mapStateToProps", () => {
|
||||
it("selects correct props", () => {
|
||||
const state = fakeState();
|
||||
const result = mapStateToProps(state);
|
||||
expect(result).toBeTruthy();
|
||||
expect(result.selected).toBeUndefined();
|
||||
expect(result.plants.length).toBe(2);
|
||||
expect(result.dispatch).toBe(state.dispatch);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -16,6 +16,7 @@ import {
|
|||
} from "../../../__test_support__/fake_state/resources";
|
||||
import { save, overwrite, edit } from "../../../api/crud";
|
||||
import { toggleHoveredPlant } from "../../actions";
|
||||
import { DEFAULT_ICON } from "../../../open_farm/icons";
|
||||
|
||||
describe("<GroupDetailActive/>", () => {
|
||||
function fakeProps() {
|
||||
|
@ -84,6 +85,19 @@ describe("<GroupDetailActive/>", () => {
|
|||
expect(el.find("input").prop("defaultValue")).toContain("XYZ");
|
||||
});
|
||||
|
||||
it("provides the DEFAULT_ICON when OF has no icon to provide", () => {
|
||||
const plant = fakePlant();
|
||||
const comp = new GroupDetailActive(fakeProps());
|
||||
comp.state = {
|
||||
[plant.uuid]: {
|
||||
slug: plant.uuid,
|
||||
svg_icon: undefined
|
||||
}
|
||||
};
|
||||
const result = comp.findIcon(plant);
|
||||
expect(result).toEqual(DEFAULT_ICON);
|
||||
});
|
||||
|
||||
it("changes group name", () => {
|
||||
const NEW_NAME = "new group name";
|
||||
const wrapper = shallow(<GroupDetailActive {...fakeProps()} />);
|
||||
|
|
Loading…
Reference in New Issue