ant-design-vue/components/date-picker/__tests__/MonthPicker.test.js

30 lines
868 B
JavaScript
Raw Normal View History

2019-01-12 03:33:27 +00:00
import { mount } from '@vue/test-utils';
import { asyncExpect } from '@/tests/utils';
import moment from 'moment';
import DatePicker from '..';
import focusTest from '../../../tests/shared/focusTest';
import { openPanel, $$ } from './utils';
2018-06-09 05:14:14 +00:00
2019-01-12 03:33:27 +00:00
const { MonthPicker } = DatePicker;
2018-06-09 05:14:14 +00:00
describe('MonthPicker', () => {
2019-01-12 03:33:27 +00:00
focusTest(MonthPicker);
2018-12-08 08:47:05 +00:00
it('reset select item when popup close', async () => {
const wrapper = mount(MonthPicker, {
2020-07-25 07:46:49 +00:00
props: { value: moment('2018-07-01') },
2018-12-08 08:47:05 +00:00
sync: false,
2020-07-25 07:46:49 +00:00
attachTo: 'body',
2019-01-12 03:33:27 +00:00
});
2018-12-08 08:47:05 +00:00
await asyncExpect(() => {
2019-01-12 03:33:27 +00:00
openPanel(wrapper);
}, 0);
2018-12-08 08:47:05 +00:00
await asyncExpect(() => {
2019-01-12 03:33:27 +00:00
$$('.ant-calendar-month-panel-month')[0].click();
$$('.ant-calendar-month-panel-cell')[6]
.getAttribute('class')
.split(' ')
.includes('ant-calendar-month-panel-selected-cell');
}, 1000);
});
});