2016-12-14 14:48:09 +08:00
|
|
|
import React from 'react';
|
2017-03-15 14:25:43 +08:00
|
|
|
import { shallow, render } from 'enzyme';
|
2016-12-14 14:48:09 +08:00
|
|
|
import Radio from '../radio';
|
2017-11-19 01:41:40 +08:00
|
|
|
import focusTest from '../../../tests/shared/focusTest';
|
2016-12-14 14:48:09 +08:00
|
|
|
|
|
|
|
describe('Radio', () => {
|
2017-11-19 01:41:40 +08:00
|
|
|
focusTest(Radio);
|
|
|
|
|
2017-03-15 14:25:43 +08:00
|
|
|
it('should render correctly', () => {
|
|
|
|
const wrapper = render(<Radio className="customized">Test</Radio>);
|
2017-04-02 18:09:23 +08:00
|
|
|
expect(wrapper).toMatchSnapshot();
|
2017-03-15 14:25:43 +08:00
|
|
|
});
|
|
|
|
|
2016-12-14 14:48:09 +08:00
|
|
|
it('responses hover events', () => {
|
|
|
|
const onMouseEnter = jest.fn();
|
|
|
|
const onMouseLeave = jest.fn();
|
|
|
|
|
|
|
|
const wrapper = shallow(
|
|
|
|
<Radio
|
|
|
|
onMouseEnter={onMouseEnter}
|
|
|
|
onMouseLeave={onMouseLeave}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
wrapper.simulate('mouseenter');
|
|
|
|
expect(onMouseEnter).toHaveBeenCalled();
|
|
|
|
|
|
|
|
wrapper.simulate('mouseleave');
|
|
|
|
expect(onMouseLeave).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
});
|