Test callbacks in <WeedDetectorSlider/>

This commit is contained in:
Rick Carlino 2018-01-16 10:24:56 -07:00
parent bde24c7e78
commit e074d3dd94

View file

@ -1,5 +1,8 @@
import * as React from "react";
import { WeedDetectorSlider } from "../slider";
import { shallow } from "enzyme";
jest.useFakeTimers();
describe("Weed detector slider", () => {
it("sets props", () => {
const results = new WeedDetectorSlider({
@ -12,4 +15,20 @@ describe("Weed detector slider", () => {
expect(results.props.highest).toEqual(99);
});
it("releases the slider", () => {
const onRelease = jest.fn();
const el = shallow(<WeedDetectorSlider
onRelease={onRelease}
highest={99}
lowest={1}
lowValue={3}
highValue={5} />);
el.simulate("release", [5, 6]);
jest.runAllTimers();
expect(onRelease).toHaveBeenCalledWith([5, 6]);
const { highValue, lowValue } = el.state();
expect(highValue).toBeUndefined();
expect(lowValue).toBeUndefined();
});
});