mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-15 17:31:25 +08:00
8010cd19b6
* test: migrate part of DatePicker tests * test: migrate part of DatePicker tests * fix: update snap * test: migrate part of DatePicker tests * test: migrate part of DatePicker tests * test: migrate part of DatePicker tests * test: migrate part of DatePicker tests * test: migrate part of DatePicker tests * test: migrate part of DatePicker tests * test: remove useless methods * test: add test ignore
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import { fireEvent } from '../../../tests/utils';
|
|
import type { render } from '../../../tests/utils';
|
|
|
|
export function openPicker(wrapper: ReturnType<typeof render>, index = 0) {
|
|
fireEvent.mouseDown(wrapper.container?.querySelectorAll('input')?.[index]!);
|
|
fireEvent.focus(wrapper.container?.querySelectorAll('input')?.[index]!);
|
|
}
|
|
|
|
export function closePicker(wrapper: ReturnType<typeof render>, index = 0) {
|
|
fireEvent.blur(wrapper.container?.querySelectorAll('input')[index]!);
|
|
}
|
|
|
|
export function selectCell(wrapper: ReturnType<typeof render>, text: string | number, index = 0) {
|
|
let matchCell: HTMLTableCellElement | null = null;
|
|
const tds = wrapper.container?.querySelectorAll('table')?.[index]?.querySelectorAll('td');
|
|
tds.forEach(td => {
|
|
if (td.querySelector('div')?.innerHTML === String(text) && td.className.includes('-in-view')) {
|
|
matchCell = td;
|
|
fireEvent.click(td);
|
|
}
|
|
});
|
|
/* istanbul ignore next */
|
|
if (!matchCell) {
|
|
throw new Error('Cell not match in picker panel.');
|
|
}
|
|
return matchCell;
|
|
}
|