2018-02-01 16:12:42 +08:00
|
|
|
/* eslint-disable import/prefer-default-export */
|
|
|
|
export function selectDate(wrapper, date, index) {
|
|
|
|
let calendar = wrapper;
|
2018-02-07 14:22:35 +08:00
|
|
|
if (index !== undefined) {
|
|
|
|
calendar = wrapper.find('.ant-calendar-range-part').at(index);
|
2018-02-01 16:12:42 +08:00
|
|
|
}
|
|
|
|
calendar.find({ title: date.format('LL'), role: 'gridcell' }).simulate('click');
|
|
|
|
}
|
|
|
|
|
|
|
|
export function hasSelected(wrapper, date) {
|
2018-12-07 16:17:45 +08:00
|
|
|
return wrapper
|
|
|
|
.find({ title: date.format('LL'), role: 'gridcell' })
|
|
|
|
.hasClass('ant-calendar-selected-day');
|
2018-02-01 16:12:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export function openPanel(wrapper) {
|
|
|
|
wrapper.find('.ant-calendar-picker-input').simulate('click');
|
|
|
|
}
|
|
|
|
|
|
|
|
export function clearInput(wrapper) {
|
2018-12-07 16:17:45 +08:00
|
|
|
wrapper
|
|
|
|
.find('.ant-calendar-picker-clear')
|
|
|
|
.hostNodes()
|
|
|
|
.simulate('click');
|
2018-02-01 16:12:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export function nextYear(wrapper) {
|
|
|
|
wrapper.find('.ant-calendar-next-year-btn').simulate('click');
|
|
|
|
}
|
|
|
|
|
|
|
|
export function nextMonth(wrapper) {
|
|
|
|
wrapper.find('.ant-calendar-next-month-btn').simulate('click');
|
|
|
|
}
|
2019-12-11 23:32:19 +08:00
|
|
|
|
|
|
|
export function openPicker(wrapper, index = 0) {
|
|
|
|
wrapper
|
|
|
|
.find('input')
|
|
|
|
.at(index)
|
|
|
|
.simulate('mousedown')
|
|
|
|
.simulate('focus');
|
|
|
|
}
|
|
|
|
export function closePicker(wrapper, index = 0) {
|
|
|
|
wrapper
|
|
|
|
.find('input')
|
|
|
|
.at(index)
|
|
|
|
.simulate('blur');
|
|
|
|
}
|
|
|
|
|
|
|
|
export function selectCell(wrapper, text, index = 0) {
|
|
|
|
let matchCell;
|
|
|
|
|
|
|
|
wrapper
|
|
|
|
.find('table')
|
|
|
|
.at(index)
|
|
|
|
.find('td')
|
|
|
|
.forEach(td => {
|
|
|
|
if (td.text() === String(text) && td.props().className.includes('-in-view')) {
|
|
|
|
matchCell = td;
|
|
|
|
td.simulate('click');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!matchCell) {
|
|
|
|
throw new Error('Cell not match in picker panel.');
|
|
|
|
}
|
|
|
|
|
|
|
|
return matchCell;
|
|
|
|
}
|