mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-28 10:34:53 +00:00
40 lines
989 B
JavaScript
40 lines
989 B
JavaScript
|
|
import React from 'react';
|
||
|
|
import { shallow } from 'enzyme';
|
||
|
|
|
||
|
|
import Button from './Button';
|
||
|
|
|
||
|
|
describe('Button', () => {
|
||
|
|
it('exists', () => {
|
||
|
|
expect(Button).toBeDefined();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('basic', () => {
|
||
|
|
expect(shallow(<Button />)).toMatchSnapshot();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('#children', () => {
|
||
|
|
expect(shallow(<Button>To infinity and beyond!</Button>)).toMatchSnapshot();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('#accessibleLabel', () => {
|
||
|
|
expect(shallow(<Button accessibleLabel="I am here in the shadows" />)).toMatchSnapshot();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('#icon', () => {
|
||
|
|
expect(shallow(<Button icon="test-icon" />)).toMatchSnapshot();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('#icon changes with #isLoading', () => {
|
||
|
|
expect(shallow(<Button icon="test-icon" isLoading={true} />)).toMatchSnapshot();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('is clickable', () => {
|
||
|
|
const onClick = jest.fn();
|
||
|
|
shallow(<Button onClick={onClick} />).simulate('click', {
|
||
|
|
preventDefault() {},
|
||
|
|
stopPropagation() {},
|
||
|
|
});
|
||
|
|
expect(onClick).toHaveBeenCalledTimes(1);
|
||
|
|
});
|
||
|
|
});
|