-
Notifications
You must be signed in to change notification settings - Fork 9
/
LargeIconButton.spec.jsx
executable file
·38 lines (34 loc) · 1.13 KB
/
LargeIconButton.spec.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import React from 'react';
import { shallow, mount } from 'enzyme';
import ButtonIconLarge from './ButtonIconLarge';
describe('ButtonIconLarge', () => {
it('renders', () => {
const wrapper = shallow(<ButtonIconLarge />);
expect(wrapper.find('.ButtonIconLarge').length).toBeTruthy();
});
it('renders icon', () => {
const wrapper = mount(<ButtonIconLarge icon="TEST" title="TEST" />);
expect(wrapper.find('img').props().src).toBe('TEST');
expect(
wrapper
.find('AbstractButton')
.at(0)
.text()
.includes('TEST')
).toBeTruthy();
});
it('accepts classes passed in', () => {
const wrapper = shallow(
<ButtonIconLarge className="test" isActive isDisabled />
).render();
expect(wrapper.hasClass('test')).toBe(true);
expect(wrapper.hasClass('btn--active')).toBe(false);
expect(wrapper.hasClass('btn--disabled')).toBe(true);
});
it('onclick focuses and fires prop', () => {
const clickFunc = jest.fn();
const wrapper = mount(<ButtonIconLarge onClick={clickFunc} />);
wrapper.simulate('click');
expect(clickFunc).toHaveBeenCalled();
});
});