Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1312c3
commit dd534ba
Showing
38 changed files
with
491 additions
and
569 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,14 @@ | ||
jest.mock("../../history", () => ({ push: jest.fn() })); | ||
|
||
import * as React from "react"; | ||
import { mount } from "enzyme"; | ||
import { RawControls as Controls } from "../controls"; | ||
import { bot } from "../../__test_support__/fake_state/bot"; | ||
import { | ||
fakePeripheral, fakeWebcamFeed, fakeSensor, | ||
} from "../../__test_support__/fake_state/resources"; | ||
import { Dictionary } from "farmbot"; | ||
import { Props } from "../interfaces"; | ||
import { fakeTimeSettings } from "../../__test_support__/fake_time_settings"; | ||
import { Controls } from "../controls"; | ||
import { push } from "../../history"; | ||
|
||
describe("<Controls />", () => { | ||
const mockConfig: Dictionary<boolean> = {}; | ||
|
||
const fakeProps = (): Props => ({ | ||
dispatch: jest.fn(), | ||
bot: bot, | ||
feeds: [fakeWebcamFeed()], | ||
peripherals: [fakePeripheral()], | ||
sensors: [fakeSensor()], | ||
firmwareSettings: bot.hardware.mcu_params, | ||
shouldDisplay: () => true, | ||
getWebAppConfigVal: jest.fn(key => mockConfig[key]), | ||
sensorReadings: [], | ||
timeSettings: fakeTimeSettings(), | ||
env: {}, | ||
firmwareHardware: undefined, | ||
}); | ||
|
||
it("shows webcam widget", () => { | ||
mockConfig.hide_webcam_widget = false; | ||
const wrapper = mount(<Controls {...fakeProps()} />); | ||
const txt = wrapper.text().toLowerCase(); | ||
["webcam", "move", "peripherals", "sensors"] | ||
.map(string => expect(txt).toContain(string)); | ||
}); | ||
|
||
it("hides webcam widget", () => { | ||
mockConfig.hide_webcam_widget = true; | ||
const wrapper = mount(<Controls {...fakeProps()} />); | ||
const txt = wrapper.text().toLowerCase(); | ||
["move", "peripherals", "sensors"] | ||
.map(string => expect(txt).toContain(string)); | ||
expect(txt).not.toContain("webcam"); | ||
}); | ||
|
||
it("shows sensors widget", () => { | ||
mockConfig.hide_webcam_widget = false; | ||
mockConfig.hide_sensors = false; | ||
const wrapper = mount(<Controls {...fakeProps()} />); | ||
const txt = wrapper.text().toLowerCase(); | ||
["webcam", "move", "peripherals", "sensors"] | ||
.map(string => expect(txt).toContain(string)); | ||
}); | ||
|
||
it("hides sensors widget", () => { | ||
mockConfig.hide_webcam_widget = true; | ||
mockConfig.hide_sensors = true; | ||
const wrapper = mount(<Controls {...fakeProps()} />); | ||
const txt = wrapper.text().toLowerCase(); | ||
["move", "peripherals"] | ||
.map(string => expect(txt).toContain(string)); | ||
["webcam", "sensors"] | ||
.map(string => expect(txt).not.toContain(string)); | ||
}); | ||
|
||
it("hides sensors widget based on model", () => { | ||
mockConfig.hide_sensors = false; | ||
const p = fakeProps(); | ||
p.firmwareHardware = "express_k10"; | ||
const wrapper = mount(<Controls {...p} />); | ||
const txt = wrapper.text().toLowerCase(); | ||
["move", "peripherals"] | ||
.map(string => expect(txt).toContain(string)); | ||
["sensors"].map(string => expect(txt).not.toContain(string)); | ||
}); | ||
|
||
it("doesn't show sensor readings widget", () => { | ||
const p = fakeProps(); | ||
mockConfig.hide_sensors = true; | ||
const wrapper = mount(<Controls {...p} />); | ||
const txt = wrapper.text().toLowerCase(); | ||
expect(txt).not.toContain("sensor history"); | ||
}); | ||
|
||
it("shows sensor readings widget", () => { | ||
const p = fakeProps(); | ||
mockConfig.hide_sensors = false; | ||
const wrapper = mount(<Controls {...p} />); | ||
const txt = wrapper.text().toLowerCase(); | ||
expect(txt).toContain("sensor history"); | ||
it("redirects", () => { | ||
const wrapper = mount(<Controls />); | ||
expect(wrapper.text().toLowerCase()).toContain("redirecting"); | ||
expect(push).toHaveBeenCalledWith("/app/designer/controls"); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.