diff --git a/frontend/__tests__/app_test.tsx b/frontend/__tests__/app_test.tsx index 930a2e070..3df5e6cb0 100644 --- a/frontend/__tests__/app_test.tsx +++ b/frontend/__tests__/app_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); let mockPath = ""; jest.mock("../history", () => ({ diff --git a/frontend/account/__tests__/index_test.tsx b/frontend/account/__tests__/index_test.tsx index 1de21ef36..92cf757e9 100644 --- a/frontend/account/__tests__/index_test.tsx +++ b/frontend/account/__tests__/index_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); jest.mock("../labs/labs_features", () => ({ LabsFeatures: () =>
})); import * as React from "react"; diff --git a/frontend/account/index.tsx b/frontend/account/index.tsx index 830d38772..658704fae 100644 --- a/frontend/account/index.tsx +++ b/frontend/account/index.tsx @@ -27,8 +27,7 @@ interface State { warnThem: boolean; } -@connect(mapStateToProps) -export class Account extends React.Component { +export class RawAccount extends React.Component { state: State = { warnThem: false }; /** WHAT WE NEED: The ability to tell users to check their email if they try @@ -113,3 +112,5 @@ export class Account extends React.Component { ; } } + +export const Account = connect(mapStateToProps)(RawAccount); diff --git a/frontend/app.tsx b/frontend/app.tsx index f6a73ba83..9a6aae89b 100644 --- a/frontend/app.tsx +++ b/frontend/app.tsx @@ -97,8 +97,7 @@ const MUST_LOAD: ResourceName[] = [ "Tool" // Sequence editor needs this for rendering. ]; -@connect(mapStateToProps) -export class App extends React.Component { +export class RawApp extends React.Component { private get isLoaded() { return (MUST_LOAD.length === intersection(this.props.loaded, MUST_LOAD).length); @@ -152,3 +151,5 @@ export class App extends React.Component {
; } } + +export const App = connect(mapStateToProps)(RawApp); diff --git a/frontend/connectivity/__tests__/connect_device/connect_device_test.ts b/frontend/connectivity/__tests__/connect_device/connect_device_test.ts index db20bbc22..fc10c21d5 100644 --- a/frontend/connectivity/__tests__/connect_device/connect_device_test.ts +++ b/frontend/connectivity/__tests__/connect_device/connect_device_test.ts @@ -10,7 +10,7 @@ import { DeepPartial } from "redux"; import { AuthState } from "../../../auth/interfaces"; import { fakeState } from "../../../__test_support__/fake_state"; -describe("connectDevice()", async () => { +describe("connectDevice()", () => { it("connects a FarmBot to the network", async () => { const auth: DeepPartial = { token: {} }; const dispatch = jest.fn(); diff --git a/frontend/connectivity/ping_mqtt.tsx b/frontend/connectivity/ping_mqtt.tsx index f085bdec1..0fc71f052 100644 --- a/frontend/connectivity/ping_mqtt.tsx +++ b/frontend/connectivity/ping_mqtt.tsx @@ -41,7 +41,7 @@ export function sendOutboundPing(bot: Farmbot) { if (!x.done) { x.done = true; pingNO(id, now()); - reject(); + reject(new Error("sendOutboundPing failed: " + id)); } }; @@ -51,9 +51,12 @@ export function sendOutboundPing(bot: Farmbot) { }); } +const beep = (bot: Farmbot) => sendOutboundPing(bot) + .then(() => { }, () => { }); // Silence errors; + export function startPinging(bot: Farmbot) { - sendOutboundPing(bot); - setInterval(() => sendOutboundPing(bot), PING_INTERVAL); + beep(bot); + setInterval(() => beep(bot), PING_INTERVAL); } export function pingAPI() { diff --git a/frontend/controls/__tests__/controls_test.tsx b/frontend/controls/__tests__/controls_test.tsx index d25d79712..e8de14c8c 100644 --- a/frontend/controls/__tests__/controls_test.tsx +++ b/frontend/controls/__tests__/controls_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); import * as React from "react"; import { mount } from "enzyme"; diff --git a/frontend/controls/controls.tsx b/frontend/controls/controls.tsx index 92405d5c3..04a86b8a3 100644 --- a/frontend/controls/controls.tsx +++ b/frontend/controls/controls.tsx @@ -12,8 +12,7 @@ import { SensorReadings } from "./sensor_readings/sensor_readings"; import { isBotOnline } from "../devices/must_be_online"; /** Controls page. */ -@connect(mapStateToProps) -export class Controls extends React.Component { +export class RawControls extends React.Component { get arduinoBusy() { return !!this.props.bot.hardware.informational_settings.busy; } @@ -92,3 +91,5 @@ export class Controls extends React.Component { ; } } + +export const Controls = connect(mapStateToProps)(RawControls); diff --git a/frontend/devices/__tests__/devices_test.tsx b/frontend/devices/__tests__/devices_test.tsx index d99dd89c7..e43cb9d68 100644 --- a/frontend/devices/__tests__/devices_test.tsx +++ b/frontend/devices/__tests__/devices_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); import * as React from "react"; import { shallow, render } from "enzyme"; diff --git a/frontend/devices/components/__tests__/farmbot_os_settings_test.tsx b/frontend/devices/components/__tests__/farmbot_os_settings_test.tsx index a42b46196..ce087cfa2 100644 --- a/frontend/devices/components/__tests__/farmbot_os_settings_test.tsx +++ b/frontend/devices/components/__tests__/farmbot_os_settings_test.tsx @@ -1,3 +1,5 @@ +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); + let mockReleaseNoteData = {}; jest.mock("axios", () => ({ get: jest.fn(() => Promise.resolve(mockReleaseNoteData)) diff --git a/frontend/devices/components/farmbot_os_settings.tsx b/frontend/devices/components/farmbot_os_settings.tsx index b37aeb327..ee4eeff5a 100644 --- a/frontend/devices/components/farmbot_os_settings.tsx +++ b/frontend/devices/components/farmbot_os_settings.tsx @@ -106,7 +106,7 @@ export class FarmbotOsSettings - + diff --git a/frontend/devices/components/fbos_settings/boot_sequence_selector.tsx b/frontend/devices/components/fbos_settings/boot_sequence_selector.tsx index 62e3fee4c..c1300508f 100644 --- a/frontend/devices/components/fbos_settings/boot_sequence_selector.tsx +++ b/frontend/devices/components/fbos_settings/boot_sequence_selector.tsx @@ -11,7 +11,7 @@ interface Props { dispatch: Function; } -function mapStateToProps(p: Everything) { +function mapStateToProps(p: Everything): Props { const { index } = p.resources; const fbosConfig = getFbosConfig(index); if (fbosConfig) { @@ -25,10 +25,11 @@ function mapStateToProps(p: Everything) { } } -@connect(mapStateToProps) -export class BootSequenceSelector extends React.Component { - +export class DisconnectedBootSequenceSelector extends React.Component { render() { return
Ey...
; } } + +export const BootSequenceSelector = + connect(mapStateToProps)(DisconnectedBootSequenceSelector); diff --git a/frontend/devices/devices.tsx b/frontend/devices/devices.tsx index 99c3da8f4..5f8808ba5 100644 --- a/frontend/devices/devices.tsx +++ b/frontend/devices/devices.tsx @@ -10,8 +10,7 @@ import { selectAllDiagnosticDumps } from "../resources/selectors"; import { getStatus } from "../connectivity/reducer_support"; import { isFwHardwareValue } from "./components/firmware_hardware_support"; -@connect(mapStateToProps) -export class Devices extends React.Component { +export class RawDevices extends React.Component { render() { if (this.props.auth) { const { botToMqtt } = this.props; @@ -61,3 +60,5 @@ export class Devices extends React.Component { } } } + +export const Devices = connect(mapStateToProps)(RawDevices); diff --git a/frontend/farm_designer/__tests__/farm_designer_test.tsx b/frontend/farm_designer/__tests__/farm_designer_test.tsx index 02e80de63..22373a23b 100644 --- a/frontend/farm_designer/__tests__/farm_designer_test.tsx +++ b/frontend/farm_designer/__tests__/farm_designer_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); let mockPath = "/app/designer/plants"; jest.mock("../../history", () => ({ @@ -12,7 +12,7 @@ jest.mock("../../api/crud", () => ({ })); import * as React from "react"; -import { FarmDesigner } from "../index"; +import { RawFarmDesigner } from "../index"; import { mount } from "enzyme"; import { Props } from "../interfaces"; import { GardenMapLegendProps } from "../map/interfaces"; @@ -27,7 +27,7 @@ import { fakeState } from "../../__test_support__/fake_state"; import { edit } from "../../api/crud"; import { BooleanSetting } from "../../session_keys"; -describe("", () => { +describe("", () => { function fakeProps(): Props { return { @@ -63,7 +63,7 @@ describe("", () => { } it("loads default map settings", () => { - const wrapper = mount(); + const wrapper = mount(); const legendProps = wrapper.find("GardenMapLegend").props() as GardenMapLegendProps; expect(legendProps.legendMenuOpen).toBeFalsy(); @@ -86,7 +86,7 @@ describe("", () => { image1.body.created_at = "2001-01-03T00:00:00.000Z"; image2.body.created_at = "2001-01-01T00:00:00.000Z"; p.latestImages = [image1, image2]; - const wrapper = mount(); + const wrapper = mount(); const legendProps = wrapper.find("GardenMapLegend").props() as GardenMapLegendProps; expect(legendProps.imageAgeInfo) @@ -95,7 +95,7 @@ describe("", () => { it("renders nav titles", () => { mockPath = "/app/designer/plants"; - const wrapper = mount(); + const wrapper = mount(); ["Map", "Plants", "Events"].map(string => expect(wrapper.text()).toContain(string)); expect(wrapper.find(".panel-nav").first().hasClass("hidden")).toBeTruthy(); @@ -105,7 +105,7 @@ describe("", () => { it("hides panel", () => { mockPath = "/app/designer"; - const wrapper = mount(); + const wrapper = mount(); ["Map", "Plants", "Events"].map(string => expect(wrapper.text()).toContain(string)); expect(wrapper.find(".panel-nav").first().hasClass("hidden")).toBeFalsy(); @@ -116,7 +116,7 @@ describe("", () => { it("renders saved garden indicator", () => { const p = fakeProps(); p.designer.openedSavedGarden = "SavedGardenUuid"; - const wrapper = mount(); + const wrapper = mount(); expect(wrapper.text().toLowerCase()).toContain("viewing saved garden"); }); @@ -126,7 +126,7 @@ describe("", () => { const dispatch = jest.fn(); state.resources = buildResourceIndex([fakeWebAppConfig()]); p.dispatch = jest.fn(x => x(dispatch, () => state)); - const wrapper = mount(); + const wrapper = mount(); wrapper.instance().toggle(BooleanSetting.show_plants)(); expect(edit).toHaveBeenCalledWith(expect.any(Object), { bot_origin_quadrant: 2 }); }); diff --git a/frontend/farm_designer/__tests__/move_to_test.tsx b/frontend/farm_designer/__tests__/move_to_test.tsx index f9b41aeb3..863b7bd70 100644 --- a/frontend/farm_designer/__tests__/move_to_test.tsx +++ b/frontend/farm_designer/__tests__/move_to_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); const mockDevice = { moveAbsolute: jest.fn(() => Promise.resolve()) }; jest.mock("../../device", () => ({ getDevice: () => mockDevice })); diff --git a/frontend/farm_designer/__tests__/settings_test.tsx b/frontend/farm_designer/__tests__/settings_test.tsx index ba8f1bc5d..bd4b9e4ec 100644 --- a/frontend/farm_designer/__tests__/settings_test.tsx +++ b/frontend/farm_designer/__tests__/settings_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); jest.mock("../../config_storage/actions", () => ({ getWebAppConfigValue: jest.fn(x => { x(); return jest.fn(() => true); }), @@ -8,7 +8,7 @@ jest.mock("../../config_storage/actions", () => ({ import * as React from "react"; import { mount, ReactWrapper } from "enzyme"; import { - DesignerSettings, DesignerSettingsProps, mapStateToProps + RawDesignerSettings, DesignerSettingsProps, mapStateToProps } from "../settings"; import { fakeState } from "../../__test_support__/fake_state"; import { BooleanSetting, NumericSetting } from "../../session_keys"; @@ -22,14 +22,14 @@ const getSetting = return setting; }; -describe("", () => { +describe("", () => { const fakeProps = (): DesignerSettingsProps => ({ dispatch: jest.fn(), getConfigValue: jest.fn(), }); it("renders settings", () => { - const wrapper = mount(); + const wrapper = mount(); expect(wrapper.text()).toContain("size"); const settings = wrapper.find(".designer-setting"); expect(settings.length).toEqual(7); @@ -38,13 +38,13 @@ describe("", () => { it("renders defaultOn setting", () => { const p = fakeProps(); p.getConfigValue = () => undefined; - const wrapper = mount(); + const wrapper = mount(); const confirmDeletion = getSetting(wrapper, 6, "confirm plant"); expect(confirmDeletion.find("button").text()).toEqual("on"); }); it("toggles setting", () => { - const wrapper = mount(); + const wrapper = mount(); const trailSetting = getSetting(wrapper, 1, "trail"); trailSetting.find("button").simulate("click"); expect(setWebAppConfigValue) @@ -54,7 +54,7 @@ describe("", () => { it("changes origin", () => { const p = fakeProps(); p.getConfigValue = () => 2; - const wrapper = mount(); + const wrapper = mount(); const originSetting = getSetting(wrapper, 5, "origin"); originSetting.find("div").last().simulate("click"); expect(setWebAppConfigValue).toHaveBeenCalledWith( diff --git a/frontend/farm_designer/farm_events/__tests__/add_farm_event_test.tsx b/frontend/farm_designer/farm_events/__tests__/add_farm_event_test.tsx index 1377c9335..9685335c2 100644 --- a/frontend/farm_designer/farm_events/__tests__/add_farm_event_test.tsx +++ b/frontend/farm_designer/farm_events/__tests__/add_farm_event_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); jest.mock("../../../history", () => ({ history: { push: jest.fn() } })); diff --git a/frontend/farm_designer/farm_events/__tests__/edit_farm_event_test.tsx b/frontend/farm_designer/farm_events/__tests__/edit_farm_event_test.tsx index b4fc9a7bb..1a6c6dff9 100644 --- a/frontend/farm_designer/farm_events/__tests__/edit_farm_event_test.tsx +++ b/frontend/farm_designer/farm_events/__tests__/edit_farm_event_test.tsx @@ -1,5 +1,5 @@ jest.mock("react-redux", () => ({ - connect: jest.fn() + connect: jest.fn(() => (x: {}) => x) })); jest.mock("../../../history", () => ({ diff --git a/frontend/farm_designer/farm_events/add_farm_event.tsx b/frontend/farm_designer/farm_events/add_farm_event.tsx index da93b2353..9656feebb 100644 --- a/frontend/farm_designer/farm_events/add_farm_event.tsx +++ b/frontend/farm_designer/farm_events/add_farm_event.tsx @@ -22,8 +22,7 @@ interface State { uuid: string; } -@connect(mapStateToPropsAddEdit) -export class AddFarmEvent +export class RawAddFarmEvent extends React.Component> { constructor(props: AddEditFarmEventProps) { @@ -122,3 +121,5 @@ export class AddFarmEvent } } } + +export const AddFarmEvent = connect(mapStateToPropsAddEdit)(RawAddFarmEvent); diff --git a/frontend/farm_designer/farm_events/edit_farm_event.tsx b/frontend/farm_designer/farm_events/edit_farm_event.tsx index ff2beca7a..f5350efa9 100644 --- a/frontend/farm_designer/farm_events/edit_farm_event.tsx +++ b/frontend/farm_designer/farm_events/edit_farm_event.tsx @@ -7,8 +7,7 @@ import { TaggedFarmEvent } from "farmbot"; import { EditFEForm } from "./edit_fe_form"; import { t } from "../../i18next_wrapper"; -@connect(mapStateToPropsAddEdit) -export class EditFarmEvent extends React.Component { +export class RawEditFarmEvent extends React.Component { redirect() { history.push("/app/designer/events"); return
{t("Loading")}...
; @@ -34,3 +33,5 @@ export class EditFarmEvent extends React.Component { return fe ? this.renderForm(fe) : this.redirect(); } } + +export const EditFarmEvent = connect(mapStateToPropsAddEdit)(RawEditFarmEvent); diff --git a/frontend/farm_designer/index.tsx b/frontend/farm_designer/index.tsx index 2d356967a..77823e463 100755 --- a/frontend/farm_designer/index.tsx +++ b/frontend/farm_designer/index.tsx @@ -45,8 +45,7 @@ export const getGridSize = export const gridOffset: AxisNumberProperty = { x: 50, y: 50 }; -@connect(mapStateToProps) -export class FarmDesigner extends React.Component> { +export class RawFarmDesigner extends React.Component> { initializeSetting = (name: keyof State, defaultValue: boolean): boolean => { @@ -201,3 +200,5 @@ export class FarmDesigner extends React.Component> { ; } } + +export const FarmDesigner = connect(mapStateToProps)(RawFarmDesigner); diff --git a/frontend/farm_designer/move_to.tsx b/frontend/farm_designer/move_to.tsx index 1c0c4e820..399f290bb 100644 --- a/frontend/farm_designer/move_to.tsx +++ b/frontend/farm_designer/move_to.tsx @@ -99,8 +99,7 @@ export class MoveToForm extends React.Component { +export class RawMoveTo extends React.Component { componentDidMount() { unselectPlant(this.props.dispatch)(); @@ -153,3 +152,5 @@ export const chooseLocation = (props: { }); } }; + +export const MoveTo = connect(mapStateToProps)(RawMoveTo); diff --git a/frontend/farm_designer/plants/__tests__/add_plant_test.tsx b/frontend/farm_designer/plants/__tests__/add_plant_test.tsx index e393506d8..aa662412b 100644 --- a/frontend/farm_designer/plants/__tests__/add_plant_test.tsx +++ b/frontend/farm_designer/plants/__tests__/add_plant_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); let mockPath = ""; jest.mock("../../../history", () => ({ diff --git a/frontend/farm_designer/plants/__tests__/create_points_test.tsx b/frontend/farm_designer/plants/__tests__/create_points_test.tsx index 9e0d91775..9698c17d8 100644 --- a/frontend/farm_designer/plants/__tests__/create_points_test.tsx +++ b/frontend/farm_designer/plants/__tests__/create_points_test.tsx @@ -1,5 +1,5 @@ jest.mock("react-redux", () => ({ - connect: jest.fn() + connect: jest.fn(() => (x: {}) => x) })); jest.mock("../../../api/crud", () => ({ @@ -13,7 +13,7 @@ jest.mock("../../../farmware/weed_detector/actions", () => ({ import * as React from "react"; import { mount, shallow } from "enzyme"; import { - CreatePoints, + RawCreatePoints as CreatePoints, CreatePointsProps, mapStateToProps } from "../create_points"; diff --git a/frontend/farm_designer/plants/__tests__/crop_catalog_test.tsx b/frontend/farm_designer/plants/__tests__/crop_catalog_test.tsx index 2839eefbc..9db5c07b6 100644 --- a/frontend/farm_designer/plants/__tests__/crop_catalog_test.tsx +++ b/frontend/farm_designer/plants/__tests__/crop_catalog_test.tsx @@ -1,5 +1,5 @@ jest.mock("react-redux", () => ({ - connect: jest.fn() + connect: jest.fn(() => (x: {}) => x) })); jest.mock("lodash", () => ({ diff --git a/frontend/farm_designer/plants/__tests__/crop_info_test.tsx b/frontend/farm_designer/plants/__tests__/crop_info_test.tsx index a0b4d8975..1139fc65e 100644 --- a/frontend/farm_designer/plants/__tests__/crop_info_test.tsx +++ b/frontend/farm_designer/plants/__tests__/crop_info_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); let mockPath = ""; jest.mock("../../../history", () => ({ diff --git a/frontend/farm_designer/plants/__tests__/plant_info_test.tsx b/frontend/farm_designer/plants/__tests__/plant_info_test.tsx index c9d3ef350..2fe2d2d52 100644 --- a/frontend/farm_designer/plants/__tests__/plant_info_test.tsx +++ b/frontend/farm_designer/plants/__tests__/plant_info_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); let mockPath = "/app/designer/plants/1"; jest.mock("../../../history", () => ({ @@ -13,7 +13,7 @@ jest.mock("../../../api/crud", () => ({ })); import * as React from "react"; -import { PlantInfo } from "../plant_info"; +import { RawPlantInfo as PlantInfo } from "../plant_info"; import { mount } from "enzyme"; import { fakePlant } from "../../../__test_support__/fake_state/resources"; import { EditPlantInfoProps } from "../../interfaces"; diff --git a/frontend/farm_designer/plants/__tests__/plant_inventory_test.tsx b/frontend/farm_designer/plants/__tests__/plant_inventory_test.tsx index 3e26de031..337484e27 100644 --- a/frontend/farm_designer/plants/__tests__/plant_inventory_test.tsx +++ b/frontend/farm_designer/plants/__tests__/plant_inventory_test.tsx @@ -1,7 +1,7 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); import * as React from "react"; -import { Plants, PlantInventoryProps } from "../plant_inventory"; +import { RawPlants, PlantInventoryProps } from "../plant_inventory"; import { mount, shallow } from "enzyme"; import { fakePlant } from "../../../__test_support__/fake_state/resources"; @@ -13,7 +13,7 @@ describe("", () => { }); it("renders", () => { - const wrapper = mount(); + const wrapper = mount(); ["Map", "Plants", "Events", @@ -25,13 +25,13 @@ describe("", () => { }); it("has link to crops", () => { - const wrapper = mount(); + const wrapper = mount(); expect(wrapper.html()).toContain("fa-plus"); expect(wrapper.html()).toContain("/app/designer/plants/crop_search"); }); it("updates search term", () => { - const wrapper = shallow(); + const wrapper = shallow(); expect(wrapper.state().searchTerm).toEqual(""); wrapper.find("input").first().simulate("change", { currentTarget: { value: "mint" } }); diff --git a/frontend/farm_designer/plants/__tests__/point_info_test.tsx b/frontend/farm_designer/plants/__tests__/point_info_test.tsx index 58818a167..5dd0095b8 100644 --- a/frontend/farm_designer/plants/__tests__/point_info_test.tsx +++ b/frontend/farm_designer/plants/__tests__/point_info_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); let mockPath = "/app/designer/points/1"; jest.mock("../../../history", () => ({ diff --git a/frontend/farm_designer/plants/__tests__/point_inventory_test.tsx b/frontend/farm_designer/plants/__tests__/point_inventory_test.tsx index bb0739bdf..65f9bb919 100644 --- a/frontend/farm_designer/plants/__tests__/point_inventory_test.tsx +++ b/frontend/farm_designer/plants/__tests__/point_inventory_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); jest.mock("../../../history", () => ({ push: jest.fn(), @@ -7,7 +7,7 @@ jest.mock("../../../history", () => ({ import * as React from "react"; import { mount, shallow } from "enzyme"; -import { Points, PointsProps } from "../point_inventory"; +import { RawPoints, PointsProps } from "../point_inventory"; import { fakePoint } from "../../../__test_support__/fake_state/resources"; import { push } from "../../../history"; import { fakeState } from "../../../__test_support__/fake_state"; @@ -16,21 +16,21 @@ import { } from "../../../__test_support__/resource_index_builder"; import { mapStateToProps } from "../point_inventory"; -describe("", () => { +describe(" />", () => { const fakeProps = (): PointsProps => ({ points: [], dispatch: jest.fn(), }); it("renders no points", () => { - const wrapper = mount(); + const wrapper = mount(); expect(wrapper.text()).toContain("No points yet."); }); it("renders points", () => { const p = fakeProps(); p.points = [fakePoint()]; - const wrapper = mount(); + const wrapper = mount(); expect(wrapper.text()).toContain("Point 1"); }); @@ -38,7 +38,7 @@ describe("", () => { const p = fakeProps(); p.points = [fakePoint()]; p.points[0].body.id = 1; - const wrapper = mount(); + const wrapper = mount(); wrapper.find(".point-search-item").first().simulate("click"); expect(push).toHaveBeenCalledWith("/app/designer/points/1"); }); @@ -48,7 +48,7 @@ describe("", () => { p.points = [fakePoint(), fakePoint()]; p.points[0].body.name = "point 0"; p.points[1].body.name = "point 1"; - const wrapper = shallow(); + const wrapper = shallow(); wrapper.find("input").first().simulate("change", { currentTarget: { value: "0" } }); expect(wrapper.state().searchTerm).toEqual("0"); @@ -59,7 +59,7 @@ describe("", () => { p.points = [fakePoint(), fakePoint()]; p.points[0].body.name = "point 0"; p.points[1].body.name = "point 1"; - const wrapper = mount(); + const wrapper = mount(); wrapper.setState({ searchTerm: "0" }); expect(wrapper.text()).not.toContain("point 1"); }); diff --git a/frontend/farm_designer/plants/__tests__/select_plants_test.tsx b/frontend/farm_designer/plants/__tests__/select_plants_test.tsx index 1dc29319f..2160fd04f 100644 --- a/frontend/farm_designer/plants/__tests__/select_plants_test.tsx +++ b/frontend/farm_designer/plants/__tests__/select_plants_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); let mockPath = ""; jest.mock("../../../history", () => ({ diff --git a/frontend/farm_designer/plants/add_plant.tsx b/frontend/farm_designer/plants/add_plant.tsx index 3718c2c83..5157ba24f 100644 --- a/frontend/farm_designer/plants/add_plant.tsx +++ b/frontend/farm_designer/plants/add_plant.tsx @@ -42,8 +42,7 @@ export interface AddPlantProps { openfarmSearch: OpenfarmSearch; } -@connect(mapStateToProps) -export class AddPlant extends React.Component { +export class RawAddPlant extends React.Component { componentDidMount() { this.props.dispatch(searchForCurrentCrop(this.props.openfarmSearch)); @@ -72,3 +71,5 @@ export class AddPlant extends React.Component { ; } } + +export const AddPlant = connect(mapStateToProps)(RawAddPlant); diff --git a/frontend/farm_designer/plants/create_points.tsx b/frontend/farm_designer/plants/create_points.tsx index af59efd00..e6d40bc48 100644 --- a/frontend/farm_designer/plants/create_points.tsx +++ b/frontend/farm_designer/plants/create_points.tsx @@ -50,8 +50,7 @@ const DEFAULTS: CurrentPointPayl = { color: "red" }; -@connect(mapStateToProps) -export class CreatePoints +export class RawCreatePoints extends React.Component> { constructor(props: CreatePointsProps) { super(props); @@ -250,3 +249,5 @@ export class CreatePoints ; } } + +export const CreatePoints = connect(mapStateToProps)(RawCreatePoints); diff --git a/frontend/farm_designer/plants/crop_catalog.tsx b/frontend/farm_designer/plants/crop_catalog.tsx index 2c115220e..2cf7c6482 100644 --- a/frontend/farm_designer/plants/crop_catalog.tsx +++ b/frontend/farm_designer/plants/crop_catalog.tsx @@ -28,8 +28,7 @@ export function mapStateToProps(props: Everything): CropCatalogProps { }; } -@connect(mapStateToProps) -export class CropCatalog extends React.Component { +export class RawCropCatalog extends React.Component { debouncedOFSearch = debounce((searchTerm: string) => { this.props.openfarmSearch(searchTerm)(this.props.dispatch); @@ -99,3 +98,5 @@ export class CropCatalog extends React.Component { ; } } + +export const CropCatalog = connect(mapStateToProps)(RawCropCatalog); diff --git a/frontend/farm_designer/plants/crop_info.tsx b/frontend/farm_designer/plants/crop_info.tsx index cdfc67422..48de0a7a1 100644 --- a/frontend/farm_designer/plants/crop_info.tsx +++ b/frontend/farm_designer/plants/crop_info.tsx @@ -219,8 +219,7 @@ export const searchForCurrentCrop = (openfarmSearch: OpenfarmSearch) => unselectPlant(dispatch)(); }; -@connect(mapStateToProps) -export class CropInfo extends React.Component { +export class RawCropInfo extends React.Component { componentDidMount() { this.props.dispatch(searchForCurrentCrop(this.props.openfarmSearch)); @@ -270,3 +269,5 @@ export class CropInfo extends React.Component { ; } } + +export const CropInfo = connect(mapStateToProps)(RawCropInfo); diff --git a/frontend/farm_designer/plants/plant_info.tsx b/frontend/farm_designer/plants/plant_info.tsx index 87f7452b3..81244227b 100644 --- a/frontend/farm_designer/plants/plant_info.tsx +++ b/frontend/farm_designer/plants/plant_info.tsx @@ -12,8 +12,7 @@ import { history, getPathArray } from "../../history"; import { destroy, edit, save } from "../../api/crud"; import { BooleanSetting } from "../../session_keys"; -@connect(mapStateToProps) -export class PlantInfo extends React.Component { +export class RawPlantInfo extends React.Component { get templates() { return isString(this.props.openedSavedGarden); } get stringyID() { return getPathArray()[this.templates ? 5 : 4] || ""; } get plant() { return this.props.findPlant(this.stringyID); } @@ -64,3 +63,5 @@ export class PlantInfo extends React.Component { return plant_info ? this.default(plant_info) : this.fallback(); } } + +export const PlantInfo = connect(mapStateToProps)(RawPlantInfo); diff --git a/frontend/farm_designer/plants/plant_inventory.tsx b/frontend/farm_designer/plants/plant_inventory.tsx index 8b0a6c1f6..dae2dc6a2 100644 --- a/frontend/farm_designer/plants/plant_inventory.tsx +++ b/frontend/farm_designer/plants/plant_inventory.tsx @@ -34,8 +34,7 @@ function mapStateToProps(props: Everything): PlantInventoryProps { }; } -@connect(mapStateToProps) -export class Plants extends React.Component { +export class RawPlants extends React.Component { state: State = { searchTerm: "" }; @@ -72,3 +71,5 @@ export class Plants extends React.Component { ; } } + +export const Plants = connect(mapStateToProps)(RawPlants); diff --git a/frontend/farm_designer/plants/point_info.tsx b/frontend/farm_designer/plants/point_info.tsx index 5634274f8..8242bfdd1 100644 --- a/frontend/farm_designer/plants/point_info.tsx +++ b/frontend/farm_designer/plants/point_info.tsx @@ -24,8 +24,7 @@ export const mapStateToProps = (props: Everything): EditPointProps => ({ findPoint: id => maybeFindPointById(props.resources.index, id), }); -@connect(mapStateToProps) -export class EditPoint extends React.Component { +export class RawEditPoint extends React.Component { get stringyID() { return getPathArray()[4] || ""; } get point() { if (this.stringyID) { @@ -84,3 +83,5 @@ export class EditPoint extends React.Component { return this.point ? this.default(this.point) : this.fallback(); } } + +export const EditPoint = connect(mapStateToProps)(RawEditPoint); diff --git a/frontend/farm_designer/plants/point_inventory.tsx b/frontend/farm_designer/plants/point_inventory.tsx index 702caaf39..6313b96c9 100644 --- a/frontend/farm_designer/plants/point_inventory.tsx +++ b/frontend/farm_designer/plants/point_inventory.tsx @@ -31,9 +31,7 @@ export function mapStateToProps(props: Everything): PointsProps { }; } -@connect(mapStateToProps) -export class Points extends React.Component { - +export class RawPoints extends React.Component { state: PointsState = { searchTerm: "" }; update = ({ currentTarget }: React.SyntheticEvent) => { @@ -71,3 +69,5 @@ export class Points extends React.Component { ; } } + +export const Points = connect(mapStateToProps)(RawPoints); diff --git a/frontend/farm_designer/plants/select_plants.tsx b/frontend/farm_designer/plants/select_plants.tsx index 163259771..68c2f8686 100644 --- a/frontend/farm_designer/plants/select_plants.tsx +++ b/frontend/farm_designer/plants/select_plants.tsx @@ -29,10 +29,7 @@ export interface SelectPlantsProps { selected: string[]; } -@connect(mapStateToProps) -export class SelectPlants - extends React.Component { - +export class RawSelectPlants extends React.Component { componentDidMount() { const { dispatch, selected } = this.props; if (selected && selected.length == 1) { @@ -116,3 +113,5 @@ export class SelectPlants ; } } + +export const SelectPlants = connect(mapStateToProps)(RawSelectPlants); diff --git a/frontend/farm_designer/point_groups/__tests__/group_detail_test.tsx b/frontend/farm_designer/point_groups/__tests__/group_detail_test.tsx index 8c7fd94c6..bd986af42 100644 --- a/frontend/farm_designer/point_groups/__tests__/group_detail_test.tsx +++ b/frontend/farm_designer/point_groups/__tests__/group_detail_test.tsx @@ -45,7 +45,7 @@ describe("", () => { mockId = -23; const store = fakeStore(); const el = mount( - + ); const result = el.find(GroupDetailActive); expect(result.length).toEqual(0); @@ -56,7 +56,7 @@ describe("", () => { mockId = GOOD_ID; const store = fakeStore(); const el = mount( - + ); const result = el.find(GroupDetailActive); expect(result.length).toEqual(1); diff --git a/frontend/farm_designer/point_groups/__tests__/group_list_panel_test.tsx b/frontend/farm_designer/point_groups/__tests__/group_list_panel_test.tsx index c7d2f97f6..406414563 100644 --- a/frontend/farm_designer/point_groups/__tests__/group_list_panel_test.tsx +++ b/frontend/farm_designer/point_groups/__tests__/group_list_panel_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); jest.mock("../../../history", () => ({ getPathArray: jest.fn(() => ["L", "O", "L"]), @@ -7,7 +7,7 @@ jest.mock("../../../history", () => ({ import React from "react"; import { mount, shallow } from "enzyme"; -import { GroupListPanel, GroupListPanelProps, mapStateToProps } from "../group_list_panel"; +import { RawGroupListPanel as GroupListPanel, GroupListPanelProps, mapStateToProps } from "../group_list_panel"; import { fakePointGroup } from "../../../__test_support__/fake_state/resources"; import { history } from "../../../history"; import { fakeState } from "../../../__test_support__/fake_state"; diff --git a/frontend/farm_designer/point_groups/group_detail.tsx b/frontend/farm_designer/point_groups/group_detail.tsx index 89e15d05a..ac667df89 100644 --- a/frontend/farm_designer/point_groups/group_detail.tsx +++ b/frontend/farm_designer/point_groups/group_detail.tsx @@ -53,8 +53,7 @@ function mapStateToProps(props: Everything): GroupDetailProps { return { plants, group, dispatch: props.dispatch }; } -@connect(mapStateToProps) -export class GroupDetail extends React.Component { +export class RawGroupDetail extends React.Component { render() { const { group } = this.props; @@ -66,3 +65,4 @@ export class GroupDetail extends React.Component { } } } +export const GroupDetail = connect(mapStateToProps)(RawGroupDetail); diff --git a/frontend/farm_designer/point_groups/group_list_panel.tsx b/frontend/farm_designer/point_groups/group_list_panel.tsx index 64e9abb89..1a6e7108b 100644 --- a/frontend/farm_designer/point_groups/group_list_panel.tsx +++ b/frontend/farm_designer/point_groups/group_list_panel.tsx @@ -28,8 +28,7 @@ export function mapStateToProps(props: Everything): GroupListPanelProps { return { groups, dispatch: props.dispatch }; } -@connect(mapStateToProps) -export class GroupListPanel extends React.Component { +export class RawGroupListPanel extends React.Component { state: State = { searchTerm: "" }; @@ -72,3 +71,5 @@ export class GroupListPanel extends React.Component ; } } + +export const GroupListPanel = connect(mapStateToProps)(RawGroupListPanel); diff --git a/frontend/farm_designer/saved_gardens/__tests__/saved_gardens_test.tsx b/frontend/farm_designer/saved_gardens/__tests__/saved_gardens_test.tsx index 55f21a26f..ce450003c 100644 --- a/frontend/farm_designer/saved_gardens/__tests__/saved_gardens_test.tsx +++ b/frontend/farm_designer/saved_gardens/__tests__/saved_gardens_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); jest.mock("../actions", () => ({ snapshotGarden: jest.fn(), diff --git a/frontend/farm_designer/saved_gardens/saved_gardens.tsx b/frontend/farm_designer/saved_gardens/saved_gardens.tsx index 74141452c..38ec06fc7 100644 --- a/frontend/farm_designer/saved_gardens/saved_gardens.tsx +++ b/frontend/farm_designer/saved_gardens/saved_gardens.tsx @@ -28,8 +28,7 @@ export const mapStateToProps = (props: Everything): SavedGardensProps => ({ openedSavedGarden: props.resources.consumers.farm_designer.openedSavedGarden, }); -@connect(mapStateToProps) -export class SavedGardens extends React.Component { +export class RawSavedGardens extends React.Component { componentDidMount() { unselectPlant(this.props.dispatch)(); @@ -104,3 +103,5 @@ export const SavedGardenHUD = (props: { dispatch: Function }) => {t("Exit")} ; + +export const SavedGardens = connect(mapStateToProps)(RawSavedGardens); diff --git a/frontend/farm_designer/settings.tsx b/frontend/farm_designer/settings.tsx index 67b781b0b..849a30a8a 100644 --- a/frontend/farm_designer/settings.tsx +++ b/frontend/farm_designer/settings.tsx @@ -26,8 +26,7 @@ export interface DesignerSettingsProps { getConfigValue: GetWebAppConfigValue; } -@connect(mapStateToProps) -export class DesignerSettings +export class RawDesignerSettings extends React.Component { render() { @@ -142,3 +141,5 @@ const OriginSelector = (props: DesignerSettingsProps) => { ; }; + +export const DesignerSettings = connect(mapStateToProps)(RawDesignerSettings); diff --git a/frontend/farm_designer/tools/__tests__/add_tool_test.tsx b/frontend/farm_designer/tools/__tests__/add_tool_test.tsx index 0b431377a..8e4c5ac97 100644 --- a/frontend/farm_designer/tools/__tests__/add_tool_test.tsx +++ b/frontend/farm_designer/tools/__tests__/add_tool_test.tsx @@ -1,10 +1,10 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); jest.mock("../../../api/crud", () => ({ initSave: jest.fn() })); import * as React from "react"; import { mount, shallow } from "enzyme"; -import { AddTool, AddToolProps, mapStateToProps } from "../add_tool"; +import { RawAddTool as AddTool, AddToolProps, mapStateToProps } from "../add_tool"; import { fakeState } from "../../../__test_support__/fake_state"; import { SaveBtn } from "../../../ui"; import { initSave } from "../../../api/crud"; diff --git a/frontend/farm_designer/tools/__tests__/edit_tool_test.tsx b/frontend/farm_designer/tools/__tests__/edit_tool_test.tsx index 9b3c8914e..140cdae2b 100644 --- a/frontend/farm_designer/tools/__tests__/edit_tool_test.tsx +++ b/frontend/farm_designer/tools/__tests__/edit_tool_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); jest.mock("../../../api/crud", () => ({ edit: jest.fn() })); @@ -9,7 +9,7 @@ jest.mock("../../../history", () => ({ import * as React from "react"; import { mount, shallow } from "enzyme"; -import { EditTool, EditToolProps, mapStateToProps } from "../edit_tool"; +import { RawEditTool as EditTool, EditToolProps, mapStateToProps } from "../edit_tool"; import { fakeTool } from "../../../__test_support__/fake_state/resources"; import { fakeState } from "../../../__test_support__/fake_state"; import { diff --git a/frontend/farm_designer/tools/__tests__/index_test.tsx b/frontend/farm_designer/tools/__tests__/index_test.tsx index 251496acf..6bf576d38 100644 --- a/frontend/farm_designer/tools/__tests__/index_test.tsx +++ b/frontend/farm_designer/tools/__tests__/index_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); jest.mock("../../../history", () => ({ history: { push: jest.fn() }, @@ -7,7 +7,7 @@ jest.mock("../../../history", () => ({ import * as React from "react"; import { mount, shallow } from "enzyme"; -import { Tools, ToolsProps, mapStateToProps } from "../index"; +import { RawTools as Tools, ToolsProps, mapStateToProps } from "../index"; import { fakeTool, fakeToolSlot } from "../../../__test_support__/fake_state/resources"; diff --git a/frontend/farm_designer/tools/add_tool.tsx b/frontend/farm_designer/tools/add_tool.tsx index 155d98c70..c651d0d8c 100644 --- a/frontend/farm_designer/tools/add_tool.tsx +++ b/frontend/farm_designer/tools/add_tool.tsx @@ -21,8 +21,7 @@ export const mapStateToProps = (props: Everything): AddToolProps => ({ dispatch: props.dispatch, }); -@connect(mapStateToProps) -export class AddTool extends React.Component { +export class RawAddTool extends React.Component { state: AddToolState = { toolName: "" }; render() { return @@ -43,3 +42,5 @@ export class AddTool extends React.Component { ; } } + +export const AddTool = connect(mapStateToProps)(RawAddTool); diff --git a/frontend/farm_designer/tools/edit_tool.tsx b/frontend/farm_designer/tools/edit_tool.tsx index dfc9a53ab..7b8110d01 100644 --- a/frontend/farm_designer/tools/edit_tool.tsx +++ b/frontend/farm_designer/tools/edit_tool.tsx @@ -27,8 +27,7 @@ export const mapStateToProps = (props: Everything): EditToolProps => ({ dispatch: props.dispatch, }); -@connect(mapStateToProps) -export class EditTool extends React.Component { +export class RawEditTool extends React.Component { state: EditToolState = { toolName: this.tool ? this.tool.body.name || "" : "" }; get stringyID() { return getPathArray()[4] || ""; } @@ -65,3 +64,5 @@ export class EditTool extends React.Component { return this.tool ? this.default(this.tool) : this.fallback(); } } + +export const EditTool = connect(mapStateToProps)(RawEditTool); diff --git a/frontend/farm_designer/tools/index.tsx b/frontend/farm_designer/tools/index.tsx index 16c24404a..4ed6efa9e 100644 --- a/frontend/farm_designer/tools/index.tsx +++ b/frontend/farm_designer/tools/index.tsx @@ -34,8 +34,7 @@ export const mapStateToProps = (props: Everything): ToolsProps => ({ dispatch: props.dispatch, }); -@connect(mapStateToProps) -export class Tools extends React.Component { +export class RawTools extends React.Component { state: ToolsState = { searchTerm: "" }; update = ({ currentTarget }: React.SyntheticEvent) => { @@ -125,3 +124,5 @@ const ToolInventoryItem = (props: ToolInventoryItemProps) =>

; + +export const Tools = connect(mapStateToProps)(RawTools); diff --git a/frontend/farmware/__tests__/farmware_test.tsx b/frontend/farmware/__tests__/farmware_test.tsx index 628aa52b2..6369a1561 100644 --- a/frontend/farmware/__tests__/farmware_test.tsx +++ b/frontend/farmware/__tests__/farmware_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); const mockDevice = { execScript: jest.fn(() => Promise.resolve({})) }; jest.mock("../../device", () => ({ getDevice: () => mockDevice })); diff --git a/frontend/farmware/index.tsx b/frontend/farmware/index.tsx index bb6aed313..5739573f3 100644 --- a/frontend/farmware/index.tsx +++ b/frontend/farmware/index.tsx @@ -115,8 +115,7 @@ export const BasicFarmwarePage = ({ farmwareName, farmware, botOnline }:

; -@connect(mapStateToProps) -export class FarmwarePage extends React.Component { +export class RawFarmwarePage extends React.Component { get current() { return this.props.currentFarmware; } get botOnline() { @@ -264,3 +263,5 @@ export class FarmwarePage extends React.Component { ; } } + +export const FarmwarePage = connect(mapStateToProps)(RawFarmwarePage); diff --git a/frontend/farmware/weed_detector/__tests__/weed_detector_test.tsx b/frontend/farmware/weed_detector/__tests__/weed_detector_test.tsx index a63b3cbf4..bb8f81710 100644 --- a/frontend/farmware/weed_detector/__tests__/weed_detector_test.tsx +++ b/frontend/farmware/weed_detector/__tests__/weed_detector_test.tsx @@ -8,16 +8,13 @@ jest.mock("../../../device", () => ({ return mockDevice; } })); - -jest.mock("react-redux", () => ({ - connect: jest.fn() -})); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); jest.mock("../../images/actions", () => ({ selectImage: jest.fn() })); import * as React from "react"; import { mount, shallow } from "enzyme"; -import { WeedDetector, namespace } from "../index"; +import { RawWeedDetector as WeedDetector, namespace } from "../index"; import { FarmwareProps } from "../../../devices/interfaces"; import { API } from "../../../api"; import { selectImage } from "../../images/actions"; diff --git a/frontend/farmware/weed_detector/index.tsx b/frontend/farmware/weed_detector/index.tsx index 7c682236a..7192a70f9 100644 --- a/frontend/farmware/weed_detector/index.tsx +++ b/frontend/farmware/weed_detector/index.tsx @@ -23,8 +23,7 @@ export const namespace = (prefix: string) => (key: string): WDENVKey => { } }; -@connect(mapStateToProps) -export class WeedDetector +export class RawWeedDetector extends React.Component> { constructor(props: FarmwareProps) { @@ -103,3 +102,5 @@ export class WeedDetector ; } } + +export const WeedDetector = connect(mapStateToProps)(RawWeedDetector); diff --git a/frontend/help/__tests__/help_test.tsx b/frontend/help/__tests__/help_test.tsx index ab966cb11..45ddc228d 100644 --- a/frontend/help/__tests__/help_test.tsx +++ b/frontend/help/__tests__/help_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); import * as React from "react"; import { mount } from "enzyme"; diff --git a/frontend/help/help.tsx b/frontend/help/help.tsx index 5f108eed1..087247740 100644 --- a/frontend/help/help.tsx +++ b/frontend/help/help.tsx @@ -11,8 +11,7 @@ export function mapStateToProps(props: Everything): { dispatch: Function } { return { dispatch }; } -@connect(mapStateToProps) -export class Help extends React.Component<{ dispatch: Function }, {}> { +export class RawHelp extends React.Component<{ dispatch: Function }, {}> { componentDidMount() { this.props.dispatch({ type: Actions.START_TOUR, payload: undefined }); @@ -27,3 +26,5 @@ export class Help extends React.Component<{ dispatch: Function }, {}> { ; } } + +export const Help = connect(mapStateToProps)(RawHelp); diff --git a/frontend/logs/__tests__/index_test.tsx b/frontend/logs/__tests__/index_test.tsx index 5c4035a0e..2389be973 100644 --- a/frontend/logs/__tests__/index_test.tsx +++ b/frontend/logs/__tests__/index_test.tsx @@ -1,10 +1,10 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); const mockStorj: Dictionary = {}; import * as React from "react"; import { mount } from "enzyme"; -import { Logs } from "../index"; +import { RawLogs as Logs } from "../index"; import { ToolTips } from "../../constants"; import { TaggedLog, Dictionary } from "farmbot"; import { NumericSetting } from "../../session_keys"; diff --git a/frontend/logs/index.tsx b/frontend/logs/index.tsx index 37539018e..ff2157571 100644 --- a/frontend/logs/index.tsx +++ b/frontend/logs/index.tsx @@ -25,8 +25,7 @@ export const formatLogTime = .utcOffset(timeSettings.utcOffset) .format(`MMM D, ${timeFormatString(timeSettings)}`); -@connect(mapStateToProps) -export class Logs extends React.Component> { +export class RawLogs extends React.Component> { /** Initialize log type verbosity level to the configured or default value. */ initialize = (name: NumberConfigKey, defaultValue: number): number => { @@ -131,3 +130,5 @@ export class Logs extends React.Component> { ; } } + +export const Logs = connect(mapStateToProps)(RawLogs); diff --git a/frontend/messages/__tests__/index_test.tsx b/frontend/messages/__tests__/index_test.tsx index 7c97e6d38..db8204273 100644 --- a/frontend/messages/__tests__/index_test.tsx +++ b/frontend/messages/__tests__/index_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); import * as React from "react"; import { mount } from "enzyme"; diff --git a/frontend/messages/index.tsx b/frontend/messages/index.tsx index 7893386c2..b1bf31a9d 100644 --- a/frontend/messages/index.tsx +++ b/frontend/messages/index.tsx @@ -7,8 +7,7 @@ import { mapStateToProps } from "./state_to_props"; import { MessagesProps } from "./interfaces"; import { Link } from "../link"; -@connect(mapStateToProps) -export class Messages extends React.Component { +export class RawMessages extends React.Component { render() { return @@ -35,3 +34,5 @@ export class Messages extends React.Component { ; } } + +export const Messages = connect(mapStateToProps)(RawMessages); diff --git a/frontend/regimens/__tests__/index_test.tsx b/frontend/regimens/__tests__/index_test.tsx index c3030d83a..bf9267de5 100644 --- a/frontend/regimens/__tests__/index_test.tsx +++ b/frontend/regimens/__tests__/index_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); jest.mock("../../history", () => ({ push: () => jest.fn(), diff --git a/frontend/regimens/index.tsx b/frontend/regimens/index.tsx index 5d61d5090..502a8c086 100644 --- a/frontend/regimens/index.tsx +++ b/frontend/regimens/index.tsx @@ -27,8 +27,7 @@ export const RegimenBackButton = (props: RegimenBackButtonProps) => { title={schedulerOpen ? t("back to regimen") : t("back to regimens")} />; }; -@connect(mapStateToProps) -export class Regimens extends React.Component { +export class RawRegimens extends React.Component { UNSAFE_componentWillMount() { if (!this.props.current) { setActiveRegimenByName(); } } @@ -87,3 +86,4 @@ export class Regimens extends React.Component { ; } } +export const Regimens = connect(mapStateToProps)(RawRegimens); diff --git a/frontend/resources/reducer_support.ts b/frontend/resources/reducer_support.ts index 18120d55d..14aa531ab 100644 --- a/frontend/resources/reducer_support.ts +++ b/frontend/resources/reducer_support.ts @@ -28,7 +28,6 @@ import { ReduxAction } from "../redux/interfaces"; import { ActionHandler } from "../redux/generate_reducer"; import { get } from "lodash"; import { Actions } from "../constants"; -import { getFbosConfig } from "./getters"; export function findByUuid(index: ResourceIndex, uuid: string): TaggedResource { const x = index.references[uuid]; diff --git a/frontend/routes.tsx b/frontend/routes.tsx index c7c5f10ff..4c75fc907 100644 --- a/frontend/routes.tsx +++ b/frontend/routes.tsx @@ -51,7 +51,7 @@ export class RootComponent extends React.Component - + diff --git a/frontend/sequences/__tests__/sequences_test.tsx b/frontend/sequences/__tests__/sequences_test.tsx index 7671b3c1e..8f1fcc7a4 100644 --- a/frontend/sequences/__tests__/sequences_test.tsx +++ b/frontend/sequences/__tests__/sequences_test.tsx @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); jest.mock("../../history", () => ({ push: jest.fn(), diff --git a/frontend/sequences/__tests__/state_to_props_test.ts b/frontend/sequences/__tests__/state_to_props_test.ts index 5479269e6..7172718a1 100644 --- a/frontend/sequences/__tests__/state_to_props_test.ts +++ b/frontend/sequences/__tests__/state_to_props_test.ts @@ -1,4 +1,4 @@ -jest.mock("react-redux", () => ({ connect: jest.fn() })); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); import { mapStateToProps } from "../state_to_props"; import { fakeState } from "../../__test_support__/fake_state"; diff --git a/frontend/sequences/sequences.tsx b/frontend/sequences/sequences.tsx index 1be72336e..0b74edb59 100644 --- a/frontend/sequences/sequences.tsx +++ b/frontend/sequences/sequences.tsx @@ -29,8 +29,7 @@ export const SequenceBackButton = (props: SequenceBackButtonProps) => { title={insertingStep ? t("back to sequence") : t("back to sequences")} />; }; -@connect(mapStateToProps) -export class Sequences extends React.Component { +export class RawSequences extends React.Component { UNSAFE_componentWillMount() { if (!this.props.sequence) { setActiveSequenceByName(); } } @@ -90,3 +89,5 @@ export class Sequences extends React.Component { ; } } + +export const Sequences = connect(mapStateToProps)(RawSequences); diff --git a/frontend/tools/__tests__/index_test.tsx b/frontend/tools/__tests__/index_test.tsx index a51a9d317..44a83def5 100644 --- a/frontend/tools/__tests__/index_test.tsx +++ b/frontend/tools/__tests__/index_test.tsx @@ -1,6 +1,4 @@ -jest.mock("react-redux", () => ({ - connect: jest.fn() -})); +jest.mock("react-redux", () => ({ connect: jest.fn(() => (x: {}) => x) })); import * as React from "react"; import { mount, shallow } from "enzyme"; diff --git a/frontend/tools/index.tsx b/frontend/tools/index.tsx index 0ac312f1c..ebaa70ef4 100644 --- a/frontend/tools/index.tsx +++ b/frontend/tools/index.tsx @@ -5,8 +5,7 @@ import { Col, Row, Page } from "../ui"; import { ToolBayList, ToolBayForm, ToolList, ToolForm } from "./components"; import { mapStateToProps } from "./state_to_props"; -@connect(mapStateToProps) -export class Tools extends React.Component> { +export class RawTools extends React.Component> { state: ToolsState = { editingBays: false, editingTools: false }; toggle = (name: keyof ToolsState) => @@ -48,3 +47,5 @@ export class Tools extends React.Component> { ; } } + +export const Tools = connect(mapStateToProps)(RawTools); diff --git a/typings/index.d.ts b/typings/index.d.ts index 494c4673d..c226cd127 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1,5 +1,3 @@ -/// - /** This contains all of the global ENV vars passed from server => client. * Previously was `process.env.XYZ`. */ declare var globalConfig: { [k: string]: string }; diff --git a/typings/react-redux.d.ts b/typings/react-redux.d.ts deleted file mode 100644 index 862e6bc02..000000000 --- a/typings/react-redux.d.ts +++ /dev/null @@ -1,65 +0,0 @@ -// Type definitions for react-redux 2.1.2 -// Project: https://github.com/rackt/react-redux -// Definitions by: Qubo -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare module "react-redux" { - import { Component } from 'react'; - import { Store, Dispatch, Action, AnyAction, ActionCreator } from 'redux'; - - export class ElementClass extends Component { } - export interface ClassDecorator { - (component: T): T - } - - /** - * Connects a React component to a Redux store. - * @param mapStateToProps - * @param mapDispatchToProps - * @param mergeProps - * @param options - */ - export function connect(mapStateToProps?: MapStateToProps, - mapDispatchToProps?: MapDispatchToPropsFunction | MapDispatchToPropsObject, - mergeProps?: MergeProps, - options?: Options): ClassDecorator; - - interface MapStateToProps { - (state: any, ownProps?: any): any; - } - - interface MapDispatchToPropsFunction { - (dispatch: Dispatch, ownProps?: any): any; - } - - interface MapDispatchToPropsObject { - [name: string]: ActionCreator; - } - - interface MergeProps { - (stateProps: any, dispatchProps: any, ownProps: any): any; - } - - interface Options { - /** - * If true, implements shouldComponentUpdate and shallowly compares the result of mergeProps, - * preventing unnecessary updates, assuming that the component is a “pure” component - * and does not rely on any input or state other than its props and the selected Redux store’s state. - * Defaults to true. - * @default true - */ - pure: boolean; - } - - export interface ProviderProps { - /** - * The single Redux store in your application. - */ - store: Store; - } - - /** - * Makes the Redux store available to the connect() calls in the component hierarchy below. - */ - export class Provider extends Component> { } -}