2018-06-09 13:14:14 +08:00
|
|
|
/* eslint-disable import/prefer-default-export */
|
2019-01-12 11:33:27 +08:00
|
|
|
export function $$(className) {
|
|
|
|
return document.body.querySelectorAll(className);
|
2018-06-09 13:14:14 +08:00
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
export function hasSelected(wrapper, date) {
|
|
|
|
return document.body
|
|
|
|
.querySelector(`[title="${date.format('LL')}"][role="gridcell"]`)
|
|
|
|
.getAttribute('class')
|
|
|
|
.split(' ')
|
|
|
|
.includes('ant-calendar-selected-day');
|
2018-06-09 13:14:14 +08:00
|
|
|
}
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
export function openPanel(wrapper) {
|
|
|
|
wrapper.find('.ant-calendar-picker-input').trigger('click');
|
2018-06-09 13:14:14 +08:00
|
|
|
}
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
export function clearInput(wrapper) {
|
|
|
|
wrapper.find('.ant-calendar-picker-clear').trigger('click');
|
2018-06-09 13:14:14 +08:00
|
|
|
}
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
export function nextYear() {
|
|
|
|
$$('.ant-calendar-next-year-btn')[0].click();
|
2018-06-09 13:14:14 +08:00
|
|
|
}
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
export function nextMonth() {
|
|
|
|
$$('.ant-calendar-next-month-btn')[0].click();
|
2018-06-09 13:14:14 +08:00
|
|
|
}
|
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
export function selectDateFromBody(date, index) {
|
|
|
|
let calendar = document.body;
|
2018-06-09 13:14:14 +08:00
|
|
|
if (index !== undefined) {
|
2019-01-12 11:33:27 +08:00
|
|
|
calendar = document.body.querySelectorAll('.ant-calendar-range-part')[index];
|
2018-06-09 13:14:14 +08:00
|
|
|
}
|
2019-01-12 11:33:27 +08:00
|
|
|
calendar.querySelector(`[title="${date.format('LL')}"][role="gridcell"]`).click();
|
2018-06-09 13:14:14 +08:00
|
|
|
}
|