jest config updates
parent
7541ba14dc
commit
e1286a60bc
|
@ -14,7 +14,7 @@
|
|||
"start": "echo 'use `rails api:start`'",
|
||||
"heroku-postbuild": "webpack --config=./config/webpack.prod.js",
|
||||
"webpack": "./node_modules/.bin/webpack-dev-server --config config/webpack.dev.js",
|
||||
"test-slow": "jest --coverage --no-cache -w 2",
|
||||
"test-slow": "jest --coverage --no-cache -w 4",
|
||||
"test": "jest --no-coverage --cache -w 5",
|
||||
"typecheck": "./node_modules/.bin/tsc --noEmit --jsx preserve"
|
||||
},
|
||||
|
@ -101,6 +101,8 @@
|
|||
"webpack-notifier": "^1.5.0"
|
||||
},
|
||||
"jest": {
|
||||
"clearMocks": true,
|
||||
"logHeapUsage": true,
|
||||
"globals": {
|
||||
"globalConfig": {
|
||||
"NODE_ENV": "development",
|
||||
|
|
|
@ -13,10 +13,6 @@ import { bot } from "../__test_support__/fake_state/bot";
|
|||
import { ControlsPopupProps } from "../controls/interfaces";
|
||||
|
||||
describe("<ControlsPopup />", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const fakeProps = (): ControlsPopupProps => {
|
||||
return {
|
||||
dispatch: jest.fn(),
|
||||
|
|
|
@ -54,7 +54,6 @@ function fakeResponse(config: Partial<FakeProps>): AxiosResponse {
|
|||
|
||||
describe("responseFulfilled", () => {
|
||||
it("won't fire for webcam feed updates", () => {
|
||||
jest.clearAllMocks();
|
||||
const resp = fakeResponse({
|
||||
method: "post",
|
||||
url: "https://staging.farmbot.io/api/webcam_feeds/"
|
||||
|
@ -65,10 +64,6 @@ describe("responseFulfilled", () => {
|
|||
});
|
||||
|
||||
describe("responseRejected", () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("undefined error", async () => {
|
||||
await expect(responseRejected(undefined)).rejects.toEqual(undefined);
|
||||
expect(dispatchNetworkUp).not.toHaveBeenCalled();
|
||||
|
|
|
@ -29,10 +29,6 @@ import { auth } from "../__test_support__/fake_state/token";
|
|||
import { Session } from "../session";
|
||||
|
||||
describe("<RootComponent />", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("clears session when not authorized", () => {
|
||||
mockAuth = undefined;
|
||||
mockPathname = "/app/account";
|
||||
|
|
|
@ -7,10 +7,6 @@ import { API } from "../../api/api";
|
|||
import { error } from "farmbot-toastr";
|
||||
|
||||
describe("<ChangePassword/>", function () {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
function testCase() {
|
||||
const el = mount(<ChangePassword />);
|
||||
return {
|
||||
|
|
|
@ -36,14 +36,12 @@ describe("AJAX data tracking", () => {
|
|||
betterCompact(Object.values(store.getState().resources.index.references));
|
||||
|
||||
it("sets consistency when calling destroy()", () => {
|
||||
jest.clearAllMocks();
|
||||
const uuid = store.getState().resources.index.byKind.Tool[0];
|
||||
store.dispatch(destroy(uuid));
|
||||
expect(maybeStartTracking).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("sets consistency when calling saveAll()", () => {
|
||||
jest.clearAllMocks();
|
||||
const r = resources().map(x => {
|
||||
x.specialStatus = SpecialStatus.DIRTY;
|
||||
return x;
|
||||
|
@ -56,7 +54,6 @@ describe("AJAX data tracking", () => {
|
|||
});
|
||||
|
||||
it("sets consistency when calling initSave()", () => {
|
||||
jest.clearAllMocks();
|
||||
store.dispatch(initSave(resources()[0]));
|
||||
expect(maybeStartTracking).toHaveBeenCalled();
|
||||
});
|
||||
|
|
|
@ -27,7 +27,6 @@ import { destroyOK, destroyNO } from "../../resources/actions";
|
|||
|
||||
describe("destroy", () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
mockResource.body.id = 1;
|
||||
mockResource.kind = "Regimen";
|
||||
});
|
||||
|
|
|
@ -41,9 +41,6 @@ describe("getWebAppConfigValue", () => {
|
|||
});
|
||||
|
||||
describe("setWebAppConfigValue", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
const getState = jest.fn(() => ({ resources: { index: {} } }));
|
||||
|
||||
it("sets a numeric setting value", () => {
|
||||
|
|
|
@ -20,7 +20,6 @@ describe("handleInbound()", () => {
|
|||
const getState: GetState = jest.fn(fakeState);
|
||||
|
||||
it("handles SKIP", () => {
|
||||
jest.clearAllMocks();
|
||||
const fixtr: SkipMqttData = { status: "SKIP" };
|
||||
const result = handleInbound(dispatch, getState, fixtr);
|
||||
expect(result).toBeUndefined();
|
||||
|
@ -29,7 +28,6 @@ describe("handleInbound()", () => {
|
|||
});
|
||||
|
||||
it("handles ERR", () => {
|
||||
jest.clearAllMocks();
|
||||
const fixtr: BadMqttData = { status: "ERR", reason: "Whatever" };
|
||||
const result = handleInbound(dispatch, getState, fixtr);
|
||||
expect(result).toBeUndefined();
|
||||
|
@ -38,7 +36,6 @@ describe("handleInbound()", () => {
|
|||
});
|
||||
|
||||
it("handles UPDATE", () => {
|
||||
jest.clearAllMocks();
|
||||
const fixtr: UpdateMqttData = {
|
||||
status: "UPDATE",
|
||||
kind: "Sequence",
|
||||
|
@ -51,7 +48,6 @@ describe("handleInbound()", () => {
|
|||
});
|
||||
|
||||
it("handles DELETE when the record is in system", () => {
|
||||
jest.clearAllMocks();
|
||||
const i = getState().resources.index.byKind.Sequence;
|
||||
// Pick an ID that we know will be in the DB
|
||||
const id = parseInt(Object.values(i)[0].split(".")[1], 10);
|
||||
|
@ -62,7 +58,6 @@ describe("handleInbound()", () => {
|
|||
});
|
||||
|
||||
it("handles DELETE when the record is *not* in system", () => {
|
||||
jest.clearAllMocks();
|
||||
const fixtr: DeleteMqttData = {
|
||||
status: "DELETE",
|
||||
kind: "Sequence",
|
||||
|
|
|
@ -16,7 +16,6 @@ import { bothUp, batchInitResources } from "../connect_device";
|
|||
|
||||
describe("BatchQueue", () => {
|
||||
it("calls bothUp() to track network connectivity", () => {
|
||||
jest.clearAllMocks();
|
||||
mockThrottleStatus.value = false;
|
||||
const q = new BatchQueue(1);
|
||||
const log = fakeLog();
|
||||
|
@ -27,7 +26,6 @@ describe("BatchQueue", () => {
|
|||
});
|
||||
|
||||
it("does nothing when throttled", () => {
|
||||
jest.clearAllMocks();
|
||||
mockThrottleStatus.value = true;
|
||||
const q = new BatchQueue(1);
|
||||
q.push(fakeLog());
|
||||
|
|
|
@ -59,10 +59,6 @@ function expectActive() {
|
|||
}
|
||||
|
||||
describe("ping util", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("sets the LAST_PING_(IN|OUT) in bot state", () => {
|
||||
const bot = fakeBot();
|
||||
writePing(bot, "in");
|
||||
|
|
|
@ -6,10 +6,6 @@ import { AxisInputBoxGroupProps } from "../interfaces";
|
|||
import { clickButton } from "../../__test_support__/helpers";
|
||||
|
||||
describe("<AxisInputBoxGroup />", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const props: AxisInputBoxGroupProps = {
|
||||
position: { x: undefined, y: undefined, z: undefined },
|
||||
onCommit: jest.fn(),
|
||||
|
|
|
@ -34,7 +34,6 @@ describe("<DirectionButton/>", function () {
|
|||
const buttonProps = fakeButtonProps();
|
||||
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
buttonProps.disabled = false;
|
||||
});
|
||||
|
||||
|
|
|
@ -18,10 +18,6 @@ import { JogMovementControlsProps } from "../interfaces";
|
|||
import { bot } from "../../__test_support__/fake_state/bot";
|
||||
|
||||
describe("<JogButtons/>", function () {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const jogButtonProps = (): JogMovementControlsProps => {
|
||||
return {
|
||||
stepSize: 100,
|
||||
|
|
|
@ -24,10 +24,6 @@ import { Actions } from "../../constants";
|
|||
import { clickButton } from "../../__test_support__/helpers";
|
||||
|
||||
describe("<Move />", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const mockConfig: Dictionary<boolean> = {};
|
||||
|
||||
function fakeProps(): MoveProps {
|
||||
|
|
|
@ -3,10 +3,6 @@ import { mount } from "enzyme";
|
|||
import { ToggleButton } from "../toggle_button";
|
||||
|
||||
describe("<ToggleButton/>", function () {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("calls toggle action", () => {
|
||||
const toggle = jest.fn();
|
||||
const toggleButton = mount(<ToggleButton
|
||||
|
|
|
@ -13,10 +13,6 @@ import { SpecialStatus } from "../../../resources/tagged_resources";
|
|||
import { error } from "farmbot-toastr";
|
||||
|
||||
describe("<Peripherals />", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
function fakeProps(): PeripheralsProps {
|
||||
return {
|
||||
bot,
|
||||
|
|
|
@ -12,10 +12,6 @@ import { TaggedPeripheral, SpecialStatus } from "../../../resources/tagged_resou
|
|||
import { Pins } from "farmbot/dist";
|
||||
|
||||
describe("<PeripheralList/>", function () {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const peripherals: TaggedPeripheral[] = [
|
||||
{
|
||||
uuid: "Peripheral.2.2",
|
||||
|
|
|
@ -13,10 +13,6 @@ import { clickButton } from "../../../__test_support__/helpers";
|
|||
import { SpecialStatus } from "../../../resources/tagged_resources";
|
||||
|
||||
describe("<Sensors />", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
function fakeProps(): SensorsProps {
|
||||
const fakeSensor1 = fakeSensor();
|
||||
const fakeSensor2 = fakeSensor();
|
||||
|
|
|
@ -6,10 +6,6 @@ import { SensorFormProps } from "../interfaces";
|
|||
import { fakeSensor } from "../../../__test_support__/fake_state/resources";
|
||||
|
||||
describe("<SensorForm/>", function () {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const fakeProps = (): SensorFormProps => {
|
||||
const fakeSensor1 = fakeSensor();
|
||||
const fakeSensor2 = fakeSensor();
|
||||
|
|
|
@ -13,10 +13,6 @@ import { fakeSensor } from "../../../__test_support__/fake_state/resources";
|
|||
import { SensorListProps } from "../interfaces";
|
||||
|
||||
describe("<SensorList/>", function () {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const fakeProps = (): SensorListProps => {
|
||||
const pins: Pins = {
|
||||
50: {
|
||||
|
|
|
@ -53,10 +53,6 @@ import { bot } from "../../__test_support__/fake_state/bot";
|
|||
import { success, error, warning, info } from "farmbot-toastr";
|
||||
|
||||
describe("checkControllerUpdates()", function () {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("calls checkUpdates", async () => {
|
||||
await actions.checkControllerUpdates();
|
||||
expect(mockDevice.checkUpdates).toHaveBeenCalled();
|
||||
|
@ -65,10 +61,6 @@ describe("checkControllerUpdates()", function () {
|
|||
});
|
||||
|
||||
describe("powerOff()", function () {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("calls powerOff", async () => {
|
||||
await actions.powerOff();
|
||||
expect(mockDevice.powerOff).toHaveBeenCalled();
|
||||
|
@ -77,10 +69,6 @@ describe("powerOff()", function () {
|
|||
});
|
||||
|
||||
describe("factoryReset()", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("doesn't call factoryReset", async () => {
|
||||
window.confirm = () => false;
|
||||
await actions.factoryReset();
|
||||
|
@ -95,10 +83,6 @@ describe("factoryReset()", () => {
|
|||
});
|
||||
|
||||
describe("reboot()", function () {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("calls reboot", async () => {
|
||||
await actions.reboot();
|
||||
expect(mockDevice.reboot).toHaveBeenCalled();
|
||||
|
@ -107,10 +91,6 @@ describe("reboot()", function () {
|
|||
});
|
||||
|
||||
describe("emergencyLock() / emergencyUnlock", function () {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("calls emergencyLock", () => {
|
||||
actions.emergencyLock();
|
||||
expect(mockDevice.emergencyLock).toHaveBeenCalled();
|
||||
|
@ -124,10 +104,6 @@ describe("emergencyLock() / emergencyUnlock", function () {
|
|||
});
|
||||
|
||||
describe("sync()", function () {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("doesn't call sync: disconnected", () => {
|
||||
const getState = () => fakeState();
|
||||
actions.sync()(jest.fn(), getState);
|
||||
|
@ -138,10 +114,6 @@ describe("sync()", function () {
|
|||
});
|
||||
|
||||
describe("execSequence()", function () {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("calls execSequence", async () => {
|
||||
const s = fakeSequence().body;
|
||||
await actions.execSequence(s);
|
||||
|
@ -158,10 +130,6 @@ describe("execSequence()", function () {
|
|||
});
|
||||
|
||||
describe("MCUFactoryReset()", function () {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("doesn't call resetMCU", () => {
|
||||
window.confirm = () => false;
|
||||
actions.MCUFactoryReset();
|
||||
|
@ -183,10 +151,6 @@ describe("requestDiagnostic", () => {
|
|||
});
|
||||
|
||||
describe("settingToggle()", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("toggles mcu param via updateMcu", async () => {
|
||||
bot.hardware.mcu_params.param_mov_nr_retry = 0;
|
||||
const sourceSetting = (x: McuParamName) =>
|
||||
|
@ -225,10 +189,6 @@ describe("settingToggle()", () => {
|
|||
});
|
||||
|
||||
describe("updateMCU()", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("updates mcu param via updateMcu", async () => {
|
||||
bot.hardware.mcu_params.param_mov_nr_retry = 0;
|
||||
const state = fakeState();
|
||||
|
@ -276,10 +236,6 @@ describe("updateMCU()", () => {
|
|||
});
|
||||
|
||||
describe("pinToggle()", function () {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("calls togglePin", async () => {
|
||||
await actions.pinToggle(5);
|
||||
expect(mockDevice.togglePin).toHaveBeenCalledWith({ pin_number: 5 });
|
||||
|
@ -288,10 +244,6 @@ describe("pinToggle()", function () {
|
|||
});
|
||||
|
||||
describe("homeAll()", function () {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("calls home", async () => {
|
||||
await actions.homeAll(100);
|
||||
expect(mockDevice.home)
|
||||
|
@ -343,10 +295,6 @@ describe("resetConnectionInfo()", () => {
|
|||
});
|
||||
|
||||
describe("fetchReleases()", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("fetches latest OS release version", async () => {
|
||||
mockGetRelease = Promise.resolve({ data: { tag_name: "v1.0.0" } });
|
||||
const dispatch = jest.fn();
|
||||
|
@ -463,10 +411,6 @@ describe("fetchMinOsFeatureData()", () => {
|
|||
});
|
||||
|
||||
describe("updateConfig()", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("updates config: configUpdate", () => {
|
||||
const dispatch = jest.fn();
|
||||
const state = fakeState();
|
||||
|
|
|
@ -22,7 +22,6 @@ describe("BooleanMCUInputGroup", () => {
|
|||
const xEl = el.find(ToggleButton).at(Buttons.xAxis);
|
||||
const yEl = el.find(ToggleButton).at(Buttons.yAxis);
|
||||
const zEl = el.find(ToggleButton).at(Buttons.zAxis);
|
||||
jest.clearAllMocks();
|
||||
xEl.simulate("click");
|
||||
expect(settingToggle)
|
||||
.toHaveBeenCalledWith("encoder_invert_x", expect.any(Function), undefined);
|
||||
|
|
|
@ -12,10 +12,6 @@ import { bot } from "../../../__test_support__/fake_state/bot";
|
|||
import { fakeState } from "../../../__test_support__/fake_state";
|
||||
|
||||
describe("<BotConfigInputBox />", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const fakeProps = (): BotConfigInputBoxProps => {
|
||||
return {
|
||||
setting: "network_not_found_timer",
|
||||
|
|
|
@ -17,7 +17,6 @@ import { SpecialStatus } from "../../../resources/tagged_resources";
|
|||
|
||||
describe("<FarmbotOsSettings/>", () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
window.alert = jest.fn();
|
||||
});
|
||||
|
||||
|
|
|
@ -9,10 +9,6 @@ import { fakeFirmwareConfig } from "../../../__test_support__/fake_state/resourc
|
|||
import { clickButton } from "../../../__test_support__/helpers";
|
||||
|
||||
describe("<HardwareSettings />", () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const fakeProps = (): HardwareSettingsProps => {
|
||||
return {
|
||||
bot,
|
||||
|
|
|
@ -11,10 +11,6 @@ import { bot } from "../../../__test_support__/fake_state/bot";
|
|||
import { updateMCU } from "../../actions";
|
||||
|
||||
describe("McuInputBox", () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const fakeProps = (): McuInputBoxProps => {
|
||||
return {
|
||||
sourceFwConfig: (x) => {
|
||||
|
|
|
@ -13,10 +13,6 @@ import { AutoUpdateRowProps } from "../interfaces";
|
|||
import { fakeState } from "../../../../__test_support__/fake_state";
|
||||
|
||||
describe("<AutoUpdateRow/>", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const fakeProps = (): AutoUpdateRowProps => {
|
||||
return {
|
||||
dispatch: jest.fn(x => x(jest.fn(), fakeState)),
|
||||
|
@ -27,13 +23,13 @@ describe("<AutoUpdateRow/>", () => {
|
|||
};
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<AutoUpdateRow {...fakeProps() } />);
|
||||
const wrapper = mount(<AutoUpdateRow {...fakeProps()} />);
|
||||
expect(wrapper.text().toLowerCase()).toContain("auto update");
|
||||
});
|
||||
|
||||
it("toggles auto-update on", () => {
|
||||
bot.hardware.configuration.os_auto_update = 0;
|
||||
const wrapper = mount(<AutoUpdateRow {...fakeProps() } />);
|
||||
const wrapper = mount(<AutoUpdateRow {...fakeProps()} />);
|
||||
wrapper.find("button").first().simulate("click");
|
||||
expect(mockDevice.updateConfig)
|
||||
.toHaveBeenCalledWith({ os_auto_update: 1 });
|
||||
|
@ -41,7 +37,7 @@ describe("<AutoUpdateRow/>", () => {
|
|||
|
||||
it("toggles auto-update off", () => {
|
||||
bot.hardware.configuration.os_auto_update = 1;
|
||||
const wrapper = mount(<AutoUpdateRow {...fakeProps() } />);
|
||||
const wrapper = mount(<AutoUpdateRow {...fakeProps()} />);
|
||||
wrapper.find("button").first().simulate("click");
|
||||
expect(mockDevice.updateConfig)
|
||||
.toHaveBeenCalledWith({ os_auto_update: 0 });
|
||||
|
|
|
@ -14,10 +14,6 @@ import { CameraSelectionProps } from "../interfaces";
|
|||
import { info } from "farmbot-toastr";
|
||||
|
||||
describe("<CameraSelection/>", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const fakeProps = (): CameraSelectionProps => {
|
||||
return {
|
||||
env: {},
|
||||
|
|
|
@ -6,10 +6,6 @@ import { FarmbotOsRowProps } from "../interfaces";
|
|||
import { fakeState } from "../../../../__test_support__/fake_state";
|
||||
|
||||
describe("<FarmbotOsRow/>", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const fakeProps = (): FarmbotOsRowProps => {
|
||||
return {
|
||||
bot,
|
||||
|
|
|
@ -13,10 +13,6 @@ import { FbosDetailsProps } from "../interfaces";
|
|||
import { fakeState } from "../../../../__test_support__/fake_state";
|
||||
|
||||
describe("<FbosDetails/>", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const fakeProps = (): FbosDetailsProps => {
|
||||
return {
|
||||
botInfoSettings: bot.hardware.informational_settings,
|
||||
|
|
|
@ -18,7 +18,6 @@ describe("<OsUpdateButton/>", () => {
|
|||
beforeEach(function () {
|
||||
bot.currentOSVersion = "3.1.6";
|
||||
bot.hardware.configuration.beta_opt_in = false;
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const fakeProps = (): OsUpdateButtonProps => {
|
||||
|
|
|
@ -10,9 +10,6 @@ import { CalibrationRow } from "../calibration_row";
|
|||
import { bot } from "../../../../__test_support__/fake_state/bot";
|
||||
|
||||
describe("<HomingRow />", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
it("calls device", () => {
|
||||
const result = mount(<CalibrationRow
|
||||
hardware={bot.hardware.mcu_params}
|
||||
|
|
|
@ -15,10 +15,6 @@ import {
|
|||
import { warning } from "farmbot-toastr";
|
||||
|
||||
describe("<HomingAndCalibration />", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
function testAxisLengthInput(
|
||||
fw: string, provided: string, expected: string) {
|
||||
const dispatch = jest.fn();
|
||||
|
|
|
@ -11,10 +11,6 @@ import { HomingRow } from "../homing_row";
|
|||
import { bot } from "../../../../__test_support__/fake_state/bot";
|
||||
|
||||
describe("<HomingRow />", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("renders three buttons", () => {
|
||||
const wrapper = mount(<HomingRow
|
||||
hardware={bot.hardware.mcu_params}
|
||||
|
|
|
@ -17,10 +17,6 @@ import { panelState } from "../../../../__test_support__/control_panel_state";
|
|||
import { fakeState } from "../../../../__test_support__/fake_state";
|
||||
|
||||
describe("<Motors/>", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const fakeProps = (): MotorsProps => {
|
||||
return {
|
||||
dispatch: jest.fn(x => x(jest.fn(), fakeState)),
|
||||
|
|
|
@ -9,9 +9,6 @@ import { mount } from "enzyme";
|
|||
import { ZeroRow } from "../zero_row";
|
||||
|
||||
describe("<HomingRow />", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
it("calls device", () => {
|
||||
const result = mount(<ZeroRow botDisconnected={false} />);
|
||||
[0, 1, 2].map(i => result.find("ZeroButton").at(i).simulate("click"));
|
||||
|
|
|
@ -33,10 +33,6 @@ import {
|
|||
} from "../../../sequences/step_tiles/tile_move_absolute/test_helpers";
|
||||
|
||||
describe("<PinBindingInputGroup/>", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
function fakeProps(): PinBindingInputGroupProps {
|
||||
const fakeResources: TaggedSequence[] = [fakeSequence(), fakeSequence()];
|
||||
fakeResources[0].body.id = 1;
|
||||
|
|
|
@ -26,10 +26,6 @@ import { error } from "farmbot-toastr";
|
|||
import { sysBtnBindingData } from "../list_and_label_support";
|
||||
|
||||
describe("<PinBindingsList/>", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
function fakeProps(): PinBindingsListProps {
|
||||
const fakeResources: TaggedSequence[] = [fakeSequence(), fakeSequence()];
|
||||
fakeResources[0].body.id = 1;
|
||||
|
|
|
@ -13,10 +13,6 @@ import {
|
|||
} from "../interfaces";
|
||||
|
||||
describe("<PinBindings/>", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
function fakeProps(): PinBindingsProps {
|
||||
const fakeSequence1 = fakeSequence();
|
||||
fakeSequence1.body.id = 1;
|
||||
|
|
|
@ -17,10 +17,6 @@ import { DEFAULT_ICON } from "../../open_farm/icons";
|
|||
import { history } from "../../history";
|
||||
|
||||
describe("movePlant", () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
function movePlantTest(
|
||||
caseDescription: string,
|
||||
attempted: { x: number, y: number },
|
||||
|
|
|
@ -48,7 +48,6 @@ describe("<FarmEventForm/>", () => {
|
|||
|
||||
beforeEach(() => {
|
||||
context.form = new EditFEForm(props());
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("sets defaults", () => {
|
||||
|
|
|
@ -3,10 +3,6 @@ import { fakeFarmEvent } from "../../../__test_support__/fake_state/resources";
|
|||
import * as moment from "moment";
|
||||
|
||||
describe("maybeWarnAboutMissedTasks()", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
function testWarn(time: string): () => void {
|
||||
const callback = jest.fn();
|
||||
const fe = fakeFarmEvent("Regimen", 1);
|
||||
|
|
|
@ -98,7 +98,6 @@ function fakeProps(): GardenMapProps {
|
|||
|
||||
describe("<GardenPlant/>", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
Object.defineProperty(document, "querySelector", {
|
||||
value: () => { return { scrollLeft: 1, scrollTop: 2 }; },
|
||||
configurable: true
|
||||
|
|
|
@ -5,10 +5,6 @@ import { GridProps } from "../interfaces";
|
|||
import { fakeMapTransformProps } from "../../../__test_support__/map_transform_props";
|
||||
|
||||
describe("<Grid/>", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
function fakeProps(): GridProps {
|
||||
return {
|
||||
mapTransformProps: fakeMapTransformProps(),
|
||||
|
|
|
@ -20,10 +20,6 @@ jest.mock("../../../config_storage/actions", () => {
|
|||
});
|
||||
|
||||
describe("<ImageFilterMenu />", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
mockConfig.body.photo_filter_begin = "";
|
||||
mockConfig.body.photo_filter_end = "";
|
||||
|
||||
|
|
|
@ -13,10 +13,6 @@ import { shallow } from "enzyme";
|
|||
import { history } from "../../../../history";
|
||||
|
||||
describe("<ToolSlotLayer/>", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
function fakeProps(): ToolSlotLayerProps {
|
||||
const ts: ToolSlotPointer = {
|
||||
pointer_type: "ToolSlot",
|
||||
|
|
|
@ -19,10 +19,6 @@ import { Actions } from "../../../constants";
|
|||
import { clickButton } from "../../../__test_support__/helpers";
|
||||
|
||||
describe("<CreatePoints />", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const fakeProps = (): CreatePointsProps => {
|
||||
return {
|
||||
dispatch: jest.fn(),
|
||||
|
|
|
@ -18,10 +18,6 @@ import { fakePlant } from "../../../__test_support__/fake_state/resources";
|
|||
import { EditPlantInfoProps } from "../../interfaces";
|
||||
|
||||
describe("<EditPlantInfo />", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const fakeProps = (): EditPlantInfoProps => {
|
||||
return {
|
||||
push: jest.fn(),
|
||||
|
|
|
@ -21,7 +21,6 @@ import { MoveTo, MoveToProps, MoveToForm, MoveToFormProps } from "../move_to";
|
|||
|
||||
describe("<MoveTo />", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
mockPath = "/app/designer/plants/move_to";
|
||||
});
|
||||
|
||||
|
|
|
@ -11,10 +11,6 @@ import { clickButton } from "../../../__test_support__/helpers";
|
|||
import { history } from "../../../history";
|
||||
|
||||
describe("<PlantPanel/>", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const info: FormattedPlantInfo = {
|
||||
x: 12,
|
||||
y: 34,
|
||||
|
@ -77,10 +73,6 @@ describe("<PlantPanel/>", () => {
|
|||
});
|
||||
|
||||
describe("<EditPlantStatus />", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const fakeProps = (): EditPlantStatusProps => {
|
||||
return {
|
||||
uuid: "Plant.0.0",
|
||||
|
|
|
@ -16,7 +16,6 @@ import { clickButton } from "../../../__test_support__/helpers";
|
|||
|
||||
describe("<SelectPlants />", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
mockPath = "/app/designer/plants/select";
|
||||
});
|
||||
|
||||
|
|
|
@ -22,10 +22,6 @@ import { getDevice } from "../../device";
|
|||
import { toggleWebAppBool } from "../../config_storage/actions";
|
||||
|
||||
describe("<FarmwareConfigMenu />", () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
function fakeProps(): FarmwareConfigMenuProps {
|
||||
return {
|
||||
show: true,
|
||||
|
|
|
@ -14,10 +14,6 @@ import { fakeFarmware } from "../../__test_support__/fake_farmwares";
|
|||
import { clickButton } from "../../__test_support__/helpers";
|
||||
|
||||
describe("<FarmwareInfo />", () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const fakeProps = (): FarmwareInfoProps => {
|
||||
return {
|
||||
farmware: fakeFarmware(),
|
||||
|
|
|
@ -8,9 +8,6 @@ jest.mock("../../../device", () => ({
|
|||
import { calibrate, scanImage } from "../actions";
|
||||
|
||||
describe("scanImage()", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
it("calls out to the device", () => {
|
||||
// Run function to invoke side effects
|
||||
const thunk = scanImage(4);
|
||||
|
@ -25,9 +22,6 @@ describe("scanImage()", () => {
|
|||
});
|
||||
|
||||
describe("calibrate()", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
it("calls out to the device", () => {
|
||||
// Run function to invoke side effects
|
||||
const thunk = calibrate();
|
||||
|
|
|
@ -7,10 +7,6 @@ import { TaggedImage } from "../../../resources/tagged_resources";
|
|||
import { defensiveClone } from "../../../util";
|
||||
|
||||
describe("<ImageFlipper/>", () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
function prepareImages(data: TaggedImage[]): TaggedImage[] {
|
||||
const images: TaggedImage[] = [];
|
||||
data.forEach((item, index) => {
|
||||
|
|
|
@ -14,10 +14,6 @@ import { destroy } from "../../../api/crud";
|
|||
import { clickButton } from "../../../__test_support__/helpers";
|
||||
|
||||
describe("<Photos/>", () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
function prepareImages(data: TaggedImage[]): TaggedImage[] {
|
||||
const images: TaggedImage[] = [];
|
||||
data.forEach((item, index) => {
|
||||
|
|
|
@ -11,9 +11,6 @@ import { translateImageWorkspaceAndSave } from "../actions";
|
|||
import { scanImage, test } from "../actions";
|
||||
|
||||
describe("actions", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
it("Saves environment variables", () => {
|
||||
/** This test is just here to make sure that envSave() is actually
|
||||
* triggering side effects. */
|
||||
|
@ -35,9 +32,6 @@ describe("actions", () => {
|
|||
});
|
||||
|
||||
describe("scanImage()", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
it("calls out to the device", () => {
|
||||
// Run function to invoke side effects
|
||||
const thunk = scanImage(5);
|
||||
|
@ -52,9 +46,6 @@ describe("scanImage()", () => {
|
|||
});
|
||||
|
||||
describe("test()", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
it("calls out to the device", () => {
|
||||
// Run function to invoke side effects
|
||||
const thunk = test();
|
||||
|
|
|
@ -21,7 +21,6 @@ describe("<Body/>", () => {
|
|||
}
|
||||
|
||||
it("triggers onChange() event", () => {
|
||||
jest.clearAllMocks();
|
||||
const props = fakeProps();
|
||||
const iw = new ImageWorkspace(props);
|
||||
iw.props = props;
|
||||
|
@ -43,7 +42,6 @@ describe("<Body/>", () => {
|
|||
});
|
||||
|
||||
it("triggers numericChange()", () => {
|
||||
jest.clearAllMocks();
|
||||
const props = fakeProps();
|
||||
const iw = new ImageWorkspace(props);
|
||||
const trigger = iw.numericChange("blur");
|
||||
|
|
|
@ -10,7 +10,6 @@ describe("actions", () => {
|
|||
it("Saves environment variables", () => {
|
||||
/** This test is just here to make sure that envSave() is actually
|
||||
* triggering side effects. */
|
||||
jest.clearAllMocks();
|
||||
envSave("CAMERA_CALIBRATION_blur", 24);
|
||||
expect(getDevice().setUserEnv).toHaveBeenCalledTimes(1);
|
||||
expect(getDevice().setUserEnv)
|
||||
|
|
|
@ -36,10 +36,6 @@ import { API } from "../../api";
|
|||
import { Session } from "../../session";
|
||||
|
||||
describe("<FrontPage />", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("shows forgot password box", () => {
|
||||
const el = mount(<FrontPage />);
|
||||
expect(el.text()).not.toContain("Reset Password");
|
||||
|
@ -152,18 +148,17 @@ describe("<FrontPage />", () => {
|
|||
value: "value",
|
||||
...input
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const agreeToTerms = setField("agreeToTerms", spy)
|
||||
const agreeToTerms = setField("agreeToTerms", spy);
|
||||
const event2 = fakeEv({ checked: false });
|
||||
const expected2 = { agreeToTerms: event2.currentTarget.checked };
|
||||
agreeToTerms(event2);
|
||||
expect(spy).toHaveBeenCalledWith(expected2);
|
||||
jest.resetAllMocks();
|
||||
|
||||
|
||||
const regName = setField("regName", spy)
|
||||
const regName = setField("regName", spy);
|
||||
const event3 = fakeEv({ value: "hello!" });
|
||||
const expected3 = { regName: event3.currentTarget.value };
|
||||
regName(event3);
|
||||
|
|
|
@ -37,10 +37,6 @@ import { LogsSettingsMenuProps } from "../../interfaces";
|
|||
import { fakeState } from "../../../__test_support__/fake_state";
|
||||
|
||||
describe("<LogsSettingsMenu />", () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const fakeProps = (): LogsSettingsMenuProps => {
|
||||
return {
|
||||
setFilterLevel: () => jest.fn(),
|
||||
|
@ -52,7 +48,7 @@ describe("<LogsSettingsMenu />", () => {
|
|||
};
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<LogsSettingsMenu {...fakeProps() } />);
|
||||
const wrapper = mount(<LogsSettingsMenu {...fakeProps()} />);
|
||||
["begin", "steps", "complete"].map(string =>
|
||||
expect(wrapper.text().toLowerCase()).toContain(string));
|
||||
});
|
||||
|
@ -60,7 +56,7 @@ describe("<LogsSettingsMenu />", () => {
|
|||
function testSettingToggle(setting: ConfigurationName, position: number) {
|
||||
it("toggles setting", () => {
|
||||
bot.hardware.configuration[setting] = false;
|
||||
const wrapper = mount(<LogsSettingsMenu {...fakeProps() } />);
|
||||
const wrapper = mount(<LogsSettingsMenu {...fakeProps()} />);
|
||||
wrapper.find("button").at(position).simulate("click");
|
||||
expect(mockDevice.updateConfig)
|
||||
.toHaveBeenCalledWith({ [setting]: true });
|
||||
|
|
|
@ -12,14 +12,12 @@ import { maybeGetDevice } from "../../device";
|
|||
|
||||
describe("createRefreshTrigger", () => {
|
||||
it("never calls the bot if status is undefined", () => {
|
||||
jest.clearAllMocks();
|
||||
const go = createRefreshTrigger();
|
||||
go(undefined); go(undefined); go(undefined);
|
||||
expect(changeLastClientConnected).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("calls the bot when going from down => up", () => {
|
||||
jest.clearAllMocks();
|
||||
const go = createRefreshTrigger();
|
||||
go({ at: "?", state: "down" });
|
||||
go({ at: "?", state: "down" });
|
||||
|
|
|
@ -11,10 +11,6 @@ import { Everything } from "../../../interfaces";
|
|||
import { ToggleDayParams } from "../interfaces";
|
||||
|
||||
describe("commitBulkEditor()", () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
function newFakeState() {
|
||||
const state = fakeState();
|
||||
const fakeResources: TaggedResource[] = [
|
||||
|
@ -62,15 +58,15 @@ describe("commitBulkEditor()", () => {
|
|||
state.resources.consumers.regimens.dailyOffsetMs = 2000;
|
||||
state.resources.consumers.regimens.weeks = [{
|
||||
days:
|
||||
{
|
||||
day1: true,
|
||||
day2: false,
|
||||
day3: false,
|
||||
day4: false,
|
||||
day5: false,
|
||||
day6: false,
|
||||
day7: false
|
||||
}
|
||||
{
|
||||
day1: true,
|
||||
day2: false,
|
||||
day3: false,
|
||||
day4: false,
|
||||
day5: false,
|
||||
day6: false,
|
||||
day7: false
|
||||
}
|
||||
}];
|
||||
return state;
|
||||
}
|
||||
|
|
|
@ -5,10 +5,6 @@ import { WeekGridProps } from "../interfaces";
|
|||
import { Actions } from "../../../constants";
|
||||
|
||||
describe("<WeekGrid />", () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const weeks = [{
|
||||
days:
|
||||
{
|
||||
|
|
|
@ -16,10 +16,6 @@ import { clickButton } from "../../../__test_support__/helpers";
|
|||
import { SpecialStatus } from "../../../resources/tagged_resources";
|
||||
|
||||
describe("<RegimenEditor />", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
function fakeProps(): RegimenEditorProps {
|
||||
const regimen = fakeRegimen();
|
||||
regimen.specialStatus = SpecialStatus.DIRTY;
|
||||
|
|
|
@ -16,10 +16,6 @@ import { push } from "../../history";
|
|||
import { Actions } from "../../constants";
|
||||
|
||||
describe("copySequence()", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("copies sequence", () => {
|
||||
const sequence = fakeSequence();
|
||||
const copy = copySequence(sequence);
|
||||
|
|
|
@ -115,10 +115,6 @@ describe("<SequenceEditorMiddleActive/>", () => {
|
|||
});
|
||||
|
||||
describe("onDrop()", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("step_splice", () => {
|
||||
const dispatch = jest.fn();
|
||||
onDrop(dispatch, fakeSequence())(0, "fakeUuid");
|
||||
|
|
|
@ -23,7 +23,6 @@ describe("<TestButton/>", () => {
|
|||
}
|
||||
|
||||
function fakeProps(): TestBtnProps {
|
||||
jest.clearAllMocks();
|
||||
return {
|
||||
onClick: jest.fn(),
|
||||
onFail: jest.fn(),
|
||||
|
|
|
@ -17,10 +17,6 @@ import { fakeSequence } from "../../../__test_support__/fake_state/resources";
|
|||
import { BooleanSetting } from "../../../session_keys";
|
||||
|
||||
describe("remove()", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it("deletes step without confirmation", () => {
|
||||
const dispatch = jest.fn();
|
||||
mockStorj[BooleanSetting.confirm_step_deletion] = false;
|
||||
|
|
|
@ -16,10 +16,6 @@ import { WritePin } from "farmbot/dist";
|
|||
import { emptyState } from "../../../resources/reducer";
|
||||
|
||||
describe("Pin tile support functions", () => {
|
||||
beforeEach(function () {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
function fakeProps() {
|
||||
const currentStep: WritePin = {
|
||||
kind: "write_pin",
|
||||
|
|
|
@ -6,10 +6,6 @@ import { BlurableInput, BIProps } from "../blurable_input";
|
|||
import { error } from "farmbot-toastr";
|
||||
|
||||
describe("<BlurableInput />", () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const fakeProps = (): BIProps => {
|
||||
return {
|
||||
onCommit: jest.fn(),
|
||||
|
|
Loading…
Reference in New Issue