You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.2 KiB
40 lines
1.2 KiB
7 years ago
|
import React from 'react';
|
||
|
import Checkbox from '..';
|
||
7 years ago
|
import focusTest from '../../../tests/shared/focusTest';
|
||
5 years ago
|
import mountTest from '../../../tests/shared/mountTest';
|
||
5 years ago
|
import rtlTest from '../../../tests/shared/rtlTest';
|
||
2 years ago
|
import { fireEvent, render } from '../../../tests/utils';
|
||
|
import { resetWarned } from '../../_util/warning';
|
||
7 years ago
|
|
||
|
describe('Checkbox', () => {
|
||
4 years ago
|
focusTest(Checkbox, { refFocus: true });
|
||
5 years ago
|
mountTest(Checkbox);
|
||
5 years ago
|
rtlTest(Checkbox);
|
||
7 years ago
|
|
||
7 years ago
|
it('responses hover events', () => {
|
||
|
const onMouseEnter = jest.fn();
|
||
|
const onMouseLeave = jest.fn();
|
||
|
|
||
3 years ago
|
const { container } = render(
|
||
|
<Checkbox onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave} />,
|
||
|
);
|
||
7 years ago
|
|
||
2 years ago
|
fireEvent.mouseEnter(container.querySelector('label')!);
|
||
7 years ago
|
expect(onMouseEnter).toHaveBeenCalled();
|
||
|
|
||
2 years ago
|
fireEvent.mouseLeave(container.querySelector('label')!);
|
||
7 years ago
|
expect(onMouseLeave).toHaveBeenCalled();
|
||
|
});
|
||
5 years ago
|
|
||
|
it('warning if set `value`', () => {
|
||
|
resetWarned();
|
||
|
|
||
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||
3 years ago
|
render(<Checkbox value />);
|
||
5 years ago
|
expect(errorSpy).toHaveBeenCalledWith(
|
||
5 years ago
|
'Warning: [antd: Checkbox] `value` is not a valid prop, do you mean `checked`?',
|
||
5 years ago
|
);
|
||
|
errorSpy.mockRestore();
|
||
|
});
|
||
7 years ago
|
});
|