update feature wall
parent
eb88029bbf
commit
4f1bad1b92
|
@ -1,6 +1,4 @@
|
|||
jest.mock("react-redux", () => ({
|
||||
connect: jest.fn()
|
||||
}));
|
||||
jest.mock("react-redux", () => ({ connect: jest.fn() }));
|
||||
|
||||
let mockPath = "";
|
||||
jest.mock("../../../history", () => ({
|
||||
|
@ -8,10 +6,15 @@ jest.mock("../../../history", () => ({
|
|||
getPathArray: jest.fn(() => mockPath.split("/"))
|
||||
}));
|
||||
|
||||
jest.mock("../../../api/crud", () => ({
|
||||
destroy: jest.fn(),
|
||||
jest.mock("../../../api/crud", () => ({ destroy: jest.fn() }));
|
||||
|
||||
let mockDev = false;
|
||||
jest.mock("../../../account/dev/dev_support", () => ({
|
||||
DevSettings: { futureFeaturesEnabled: () => mockDev }
|
||||
}));
|
||||
|
||||
jest.mock("../../point_groups/actions", () => ({ createGroup: jest.fn() }));
|
||||
|
||||
import * as React from "react";
|
||||
import { mount } from "enzyme";
|
||||
import { SelectPlants, SelectPlantsProps } from "../select_plants";
|
||||
|
@ -19,6 +22,7 @@ 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";
|
||||
|
||||
describe("<SelectPlants />", () => {
|
||||
beforeEach(function () {
|
||||
|
@ -106,4 +110,16 @@ describe("<SelectPlants />", () => {
|
|||
expect(destroy).toHaveBeenCalledWith("plant.1", true);
|
||||
expect(destroy).toHaveBeenCalledWith("plant.2", true);
|
||||
});
|
||||
|
||||
it("shows other buttons", () => {
|
||||
mockDev = true;
|
||||
const wrapper = mount(<SelectPlants {...fakeProps()} />);
|
||||
expect(wrapper.text()).toContain("Create");
|
||||
});
|
||||
|
||||
it("creates group", () => {
|
||||
const wrapper = mount(<SelectPlants {...fakeProps()} />);
|
||||
wrapper.find(".blue").simulate("click");
|
||||
expect(createGroup).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -77,7 +77,7 @@ export class PlantInventoryItem extends
|
|||
key={plantId}
|
||||
onMouseEnter={() => toggle("enter")}
|
||||
onMouseLeave={() => toggle("leave")}
|
||||
onClick={click} >
|
||||
onClick={click}>
|
||||
<img
|
||||
className="plant-search-item-image"
|
||||
src={DEFAULT_ICON}
|
||||
|
@ -88,6 +88,6 @@ export class PlantInventoryItem extends
|
|||
<i className="plant-search-item-age">
|
||||
{daysOld} {t("days old")}
|
||||
</i>
|
||||
</div >;
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import * as React from "react";
|
||||
import { history } from "../../history";
|
||||
|
||||
import { connect } from "react-redux";
|
||||
import { Everything } from "../../interfaces";
|
||||
import { PlantInventoryItem } from "./plant_inventory_item";
|
||||
|
@ -14,6 +13,7 @@ import {
|
|||
} from "./designer_panel";
|
||||
import { t } from "../../i18next_wrapper";
|
||||
import { createGroup } from "../point_groups/actions";
|
||||
import { DevSettings } from "../../account/dev/dev_support";
|
||||
|
||||
export function mapStateToProps(props: Everything) {
|
||||
return {
|
||||
|
@ -29,8 +29,6 @@ export interface SelectPlantsProps {
|
|||
selected: string[];
|
||||
}
|
||||
|
||||
const YOU_SURE = "Are you sure you want to delete {{length}} plants?";
|
||||
|
||||
@connect(mapStateToProps)
|
||||
export class SelectPlants
|
||||
extends React.Component<SelectPlantsProps, {}> {
|
||||
|
@ -47,7 +45,8 @@ export class SelectPlants
|
|||
|
||||
destroySelected = (plantUUIDs: string[]) => {
|
||||
if (plantUUIDs &&
|
||||
confirm(t(YOU_SURE, { length: plantUUIDs.length }))) {
|
||||
confirm(t("Are you sure you want to delete {{length}} plants?",
|
||||
{ length: plantUUIDs.length }))) {
|
||||
plantUUIDs.map(uuid => {
|
||||
this
|
||||
.props
|
||||
|
@ -74,17 +73,19 @@ export class SelectPlants
|
|||
onClick={() => this.props.dispatch(selectPlant(undefined))}>
|
||||
{t("Select none")}
|
||||
</button>
|
||||
<button className="fb-button blue"
|
||||
onClick={() => createGroup({
|
||||
points: this.props.selected,
|
||||
dispatch: this.props.dispatch
|
||||
})}>
|
||||
{t("Create group")}
|
||||
</button>
|
||||
{/* <button className="fb-button green"
|
||||
onClick={() => { throw new Error("WIP"); }}>
|
||||
{t("Create garden")}
|
||||
</button> */}
|
||||
{DevSettings.futureFeaturesEnabled() &&
|
||||
<button className="fb-button blue"
|
||||
onClick={() => createGroup({
|
||||
points: this.props.selected,
|
||||
dispatch: this.props.dispatch
|
||||
})}>
|
||||
{t("Create group")}
|
||||
</button>}
|
||||
{DevSettings.futureFeaturesEnabled() &&
|
||||
<button className="fb-button green"
|
||||
onClick={() => { throw new Error("WIP"); }}>
|
||||
{t("Create garden")}
|
||||
</button>}
|
||||
</div>;
|
||||
|
||||
render() {
|
||||
|
|
Loading…
Reference in New Issue