-
Notifications
You must be signed in to change notification settings - Fork 9
/
ButtonStart.spec.jsx
executable file
·33 lines (29 loc) · 1022 Bytes
/
ButtonStart.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
import React from 'react';
import { shallow, mount } from 'enzyme';
import StartButton from './ButtonStart';
describe('StartButton', () => {
it('renders', () => {
const wrapper = shallow(<StartButton />);
expect(wrapper.find('.StartButton').length).toBeTruthy();
});
it('accepts classes passed in', () => {
const wrapper = shallow(
<StartButton className="test" isActive isDisabled />
).render();
expect(wrapper.hasClass('test')).toBe(true);
expect(wrapper.hasClass('btn--active')).toBe(true);
expect(wrapper.hasClass('btn--disabled')).toBe(false);
});
it('onclick fires prop', () => {
const clickFunc = jest.fn();
const wrapper = mount(<StartButton onClick={clickFunc} />);
wrapper.simulate('click');
expect(clickFunc).toHaveBeenCalled();
});
it('onblur fires prop', () => {
const clickFunc = jest.fn();
const wrapper = mount(<StartButton onBlur={clickFunc} />);
wrapper.simulate('blur');
expect(clickFunc).toHaveBeenCalled();
});
});