2017-06-29 12:54:02 -06:00
|
|
|
import * as React from "react";
|
2020-03-13 15:06:40 -06:00
|
|
|
import { LockableButton, LockableButtonProps } from "../lockable_button";
|
|
|
|
import { shallow } from "enzyme";
|
|
|
|
|
|
|
|
describe("<LockableButton />", () => {
|
|
|
|
const fakeProps = (): LockableButtonProps => ({
|
|
|
|
disabled: false,
|
|
|
|
onClick: jest.fn(),
|
|
|
|
});
|
2017-06-29 12:54:02 -06:00
|
|
|
|
|
|
|
it("does not trigger callback when clicked and disabled", () => {
|
2020-03-13 15:06:40 -06:00
|
|
|
const p = fakeProps();
|
|
|
|
p.disabled = true;
|
|
|
|
const btn = shallow(<LockableButton {...p} />);
|
2017-08-23 16:26:09 -06:00
|
|
|
btn.simulate("click");
|
2020-03-13 15:06:40 -06:00
|
|
|
expect(p.onClick).not.toHaveBeenCalled();
|
2017-06-29 12:54:02 -06:00
|
|
|
});
|
2020-03-13 15:06:40 -06:00
|
|
|
|
2017-06-29 12:54:02 -06:00
|
|
|
it("does trigger callback when clicked and enabled", () => {
|
2020-03-13 15:06:40 -06:00
|
|
|
const p = fakeProps();
|
|
|
|
p.disabled = false;
|
|
|
|
const btn = shallow(<LockableButton {...p} />);
|
2017-08-23 16:26:09 -06:00
|
|
|
btn.simulate("click");
|
2020-03-13 15:06:40 -06:00
|
|
|
expect(p.onClick).toHaveBeenCalled();
|
2017-06-29 12:54:02 -06:00
|
|
|
});
|
|
|
|
});
|