long scaling factor

pull/1108/head
gabrielburnworth 2019-02-07 16:54:47 -08:00
parent f8ab60ea38
commit fed4add808
3 changed files with 17 additions and 2 deletions

View File

@ -1,7 +1,7 @@
import * as React from "react";
import { mount } from "enzyme";
import { mount, shallow } from "enzyme";
import { EncodersAndEndStops } from "../encoders_and_endstops";
import { EncodersProps } from "../../interfaces";
import { EncodersProps, NumericMCUInputGroupProps } from "../../interfaces";
import { panelState } from "../../../../__test_support__/control_panel_state";
import { bot } from "../../../../__test_support__/fake_state/bot";
import { Dictionary } from "farmbot";
@ -30,4 +30,17 @@ describe("<EncodersAndEndStops />", () => {
const wrapper = mount(<EncodersAndEndStops {...fakeProps()} />);
expect(wrapper.text().toLowerCase()).not.toContain("invert endstops");
});
const intSizeTest = (size: "short" | "long") =>
it(`uses ${size} int scaling factor`, () => {
mockFeatures.long_scaling_factor = size === "short" ? false : true;
const wrapper = shallow(<EncodersAndEndStops {...fakeProps()} />);
const sfProps = wrapper.find("NumericMCUInputGroup").at(2)
.props() as NumericMCUInputGroupProps;
expect(sfProps.name).toEqual("Encoder Scaling");
expect(sfProps.intSize).toEqual(size);
});
intSizeTest("short");
intSizeTest("long");
});

View File

@ -76,6 +76,7 @@ export function EncodersAndEndStops(props: EncodersProps) {
x={"encoder_scaling_x"}
y={"encoder_scaling_y"}
z={"encoder_scaling_z"}
intSize={shouldDisplay(Feature.long_scaling_factor) ? "long" : "short"}
gray={encodersDisabled}
sourceFwConfig={sourceFwConfig}
dispatch={dispatch} />

View File

@ -77,6 +77,7 @@ export enum Feature {
api_farmware_installations = "api_farmware_installations",
api_farmware_env = "api_farmware_env",
use_update_channel = "use_update_channel",
long_scaling_factor = "long_scaling_factor",
}
/** Object fetched from FEATURE_MIN_VERSIONS_URL. */
export type MinOsFeatureLookup = Partial<Record<Feature, string>>;