Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
release channel UI update and cleanup
- Loading branch information
1 parent
8eaf643
commit c4025da
Showing
13 changed files
with
128 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 37 additions & 24 deletions
61
frontend/devices/components/__tests__/boolean_mcu_input_group_test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,49 @@ | ||
jest.mock("../../actions", () => ({ settingToggle: jest.fn() })); | ||
|
||
import * as React from "react"; | ||
import { mount } from "enzyme"; | ||
import { BooleanMCUInputGroup } from "../boolean_mcu_input_group"; | ||
import { ToggleButton } from "../../../controls/toggle_button"; | ||
import { settingToggle } from "../../actions"; | ||
import { bot } from "../../../__test_support__/fake_state/bot"; | ||
import { BooleanMCUInputGroupProps } from "../interfaces"; | ||
|
||
describe("BooleanMCUInputGroup", () => { | ||
const fakeProps = (): BooleanMCUInputGroupProps => ({ | ||
sourceFwConfig: x => ({ value: bot.hardware.mcu_params[x], consistent: true }), | ||
dispatch: jest.fn(), | ||
tooltip: "Tooltip", | ||
name: "Name", | ||
x: "encoder_invert_x", | ||
y: "encoder_invert_y", | ||
z: "encoder_invert_z", | ||
}); | ||
|
||
enum Buttons { xAxis, yAxis, zAxis } | ||
|
||
it("triggers callbacks", () => { | ||
const dispatch = jest.fn(); | ||
const el = mount(<BooleanMCUInputGroup | ||
sourceFwConfig={(x) => { | ||
return { value: bot.hardware.mcu_params[x], consistent: true }; | ||
}} | ||
dispatch={dispatch} | ||
tooltip={"Tooltip"} | ||
name={"Name"} | ||
x={"encoder_invert_x"} | ||
y={"encoder_invert_y"} | ||
z={"encoder_enabled_z"} />); | ||
enum Buttons { xAxis, yAxis, zAxis } | ||
const xEl = el.find(ToggleButton).at(Buttons.xAxis); | ||
const yEl = el.find(ToggleButton).at(Buttons.yAxis); | ||
const zEl = el.find(ToggleButton).at(Buttons.zAxis); | ||
xEl.simulate("click"); | ||
expect(settingToggle) | ||
.toHaveBeenCalledWith("encoder_invert_x", expect.any(Function), undefined); | ||
yEl.simulate("click"); | ||
expect(settingToggle) | ||
.toHaveBeenCalledWith("encoder_invert_y", expect.any(Function), undefined); | ||
zEl.simulate("click"); | ||
expect(settingToggle) | ||
.toHaveBeenCalledWith("encoder_enabled_z", expect.any(Function), undefined); | ||
const wrapper = mount(<BooleanMCUInputGroup {...fakeProps()} />); | ||
const xAxisButton = wrapper.find(ToggleButton).at(Buttons.xAxis); | ||
const yAxisButton = wrapper.find(ToggleButton).at(Buttons.yAxis); | ||
const zAxisButton = wrapper.find(ToggleButton).at(Buttons.zAxis); | ||
xAxisButton.simulate("click"); | ||
expect(settingToggle).toHaveBeenLastCalledWith("encoder_invert_x", | ||
expect.any(Function), undefined); | ||
yAxisButton.simulate("click"); | ||
expect(settingToggle).toHaveBeenLastCalledWith("encoder_invert_y", | ||
expect.any(Function), undefined); | ||
zAxisButton.simulate("click"); | ||
expect(settingToggle).toHaveBeenLastCalledWith("encoder_invert_z", | ||
expect.any(Function), undefined); | ||
}); | ||
|
||
it("displays gray toggles", () => { | ||
const p = fakeProps(); | ||
p.grayscale = { x: true, y: false, z: false }; | ||
const wrapper = mount(<BooleanMCUInputGroup {...p} />); | ||
const xAxisButton = wrapper.find(ToggleButton).at(Buttons.xAxis); | ||
expect(xAxisButton.props().grayscale).toBeTruthy(); | ||
const yAxisButton = wrapper.find(ToggleButton).at(Buttons.yAxis); | ||
expect(yAxisButton.props().grayscale).toBeFalsy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.