import { h } from 'preact';
import render from 'preact-render-to-json';
import { shallow } from 'preact-render-spy';
import { Button } from '@crayons';
describe(' component', () => {
it('should render a primary button when using default values', () => {
const tree = render();
expect(tree).toMatchSnapshot();
});
it('should render a secondary button when using the variant "secondary"', () => {
const tree = render();
expect(tree).toMatchSnapshot();
});
it('should render an outlined button when using the variant "outlined"', () => {
const tree = render();
expect(tree).toMatchSnapshot();
});
it('should render a danger button when using the variant "danger"', () => {
const tree = render();
expect(tree).toMatchSnapshot();
});
it('should render an enabled button when using default values', () => {
const tree = render();
expect(tree).toMatchSnapshot();
});
it('should render a disabled button when disabled is true', () => {
const tree = render();
expect(tree).toMatchSnapshot();
});
it('should render a button with addtional CSS classes when className is set', () => {
const tree = render(
,
);
expect(tree).toMatchSnapshot();
});
it('should render a button with with an icon when an icon is set and there is button text', () => {
const Icon = () => (
);
const tree = render(
,
);
expect(tree).toMatchSnapshot();
});
it('should render a button with with an icon when an icon is set and there is no button text', () => {
const Icon = () => (
);
const tree = render();
expect(tree).toMatchSnapshot();
});
it('should render a button as an anchor element if "tagName" is set to "a"', () => {
const tree = render(
,
);
expect(tree).toMatchSnapshot();
});
it('should render a button as a specific button type (HTML type attribute) when buttonType is set.', () => {
const tree = render();
expect(tree).toMatchSnapshot();
});
it('should fire the onClick event when the button is clicked.', () => {
const someEvent = jest.fn();
shallow()
.find('button')
.simulate('click');
expect(someEvent).toHaveBeenCalled();
});
it('should fire the onMouseOver event when the button is moused over.', () => {
const someEvent = jest.fn();
shallow(
,
)
.find('button')
.simulate('mouseover');
expect(someEvent).toHaveBeenCalled();
});
it('should fire the onMouseOut event when the button is moused out.', () => {
const someEvent = jest.fn();
shallow(
,
)
.find('button')
.simulate('mouseout');
expect(someEvent).toHaveBeenCalled();
});
it('should fire the onFocus event when the button is given focus.', () => {
const someEvent = jest.fn();
shallow()
.find('button')
.simulate('focus');
expect(someEvent).toHaveBeenCalled();
});
it('should fire the onBlur event when the button loses focus.', () => {
const someEvent = jest.fn();
shallow()
.find('button')
.simulate('blur');
expect(someEvent).toHaveBeenCalled();
});
});