import * as React from "react";
import renderer from "react-test-renderer";
import Button from "../Button";
import combos from "combos";
import sinon from "sinon";
import { mount } from "enzyme";
import Ink from "react-ink";
import { ButtonProps } from "../typings/Button";
function noop() {}
describe("Button Combos test", () => {
const _props = {
disabled: [true, false],
type: ["primary", "secondary", "alert", "link", "success"] as Array<
ButtonProps["type"]
>,
showRipple: [true, false],
loading: [true, false],
large: [true, false]
};
const _combos = combos(_props);
test.each(_combos)("%j", props => {
const button = renderer.create(
);
const tree = button.toJSON();
expect(tree).toMatchSnapshot();
});
});
describe("Button: functionality", () => {
test("ripple is present and click is registered correctly", () => {
const fake = sinon.fake();
const button = mount();
button.find("button").simulate("click");
expect(button.contains()).toBeTruthy();
expect(fake.calledOnce).toBeTruthy();
});
test("no ripple present and no click registered in disabled state", () => {
const fake = sinon.fake();
const button = mount(
);
expect(button.contains()).toBeFalsy();
expect(fake.called).toBeFalsy();
});
test("no ripple present and no click registered in loading state", () => {
const fake = sinon.fake();
const button = mount(
);
expect(button.contains()).toBeFalsy();
expect(fake.called).toBeFalsy();
});
});