ant-design/components/radio/__tests__/radio.test.js

27 lines
768 B
JavaScript
Raw Normal View History

2016-12-14 14:48:09 +08:00
import React from 'react';
import { mount, render } from 'enzyme';
2016-12-14 14:48:09 +08:00
import Radio from '../radio';
import focusTest from '../../../tests/shared/focusTest';
2016-12-14 14:48:09 +08:00
describe('Radio', () => {
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();
2018-12-07 20:02:01 +08:00
const wrapper = mount(<Radio onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave} />);
2016-12-14 14:48:09 +08:00
wrapper.find('label').simulate('mouseenter');
2016-12-14 14:48:09 +08:00
expect(onMouseEnter).toHaveBeenCalled();
wrapper.find('label').simulate('mouseleave');
2016-12-14 14:48:09 +08:00
expect(onMouseLeave).toHaveBeenCalled();
});
});