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 '../';
|
2018-06-09 05:14:14 +00:00
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
const { MonthPicker, WeekPicker } = DatePicker;
|
2018-06-09 05:14:14 +00:00
|
|
|
|
|
|
|
describe('MonthPicker and WeekPicker', () => {
|
|
|
|
it('render MonthPicker', async () => {
|
2019-01-12 03:33:27 +00:00
|
|
|
const birthday = moment('2000-01-01', 'YYYY-MM-DD').locale('zh-cn');
|
|
|
|
const wrapper = mount(MonthPicker, { propsData: { open: true }, sync: false });
|
2018-06-09 05:14:14 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
wrapper.setProps({ value: birthday });
|
|
|
|
});
|
2018-06-09 05:14:14 +00:00
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
const calendarWrapper = mount(
|
|
|
|
{
|
|
|
|
render() {
|
|
|
|
return wrapper.find({ name: 'Trigger' }).vm.getComponent();
|
|
|
|
},
|
2018-06-09 05:14:14 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
{ sync: false },
|
|
|
|
);
|
2018-06-09 05:14:14 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
expect(calendarWrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
2018-06-09 05:14:14 +00:00
|
|
|
|
|
|
|
it('render WeekPicker', async () => {
|
2019-01-12 03:33:27 +00:00
|
|
|
const birthday = moment('2000-01-01', 'YYYY-MM-DD').locale('zh-cn');
|
|
|
|
const wrapper = mount(WeekPicker, { propsData: { open: true }, sync: false });
|
2018-06-09 05:14:14 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
wrapper.setProps({ value: birthday });
|
|
|
|
});
|
|
|
|
const calendarWrapper = mount(
|
|
|
|
{
|
|
|
|
render() {
|
|
|
|
return wrapper.find({ name: 'Trigger' }).vm.getComponent();
|
|
|
|
},
|
2018-06-09 05:14:14 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
{ sync: false },
|
|
|
|
);
|
2018-06-09 05:14:14 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
expect(calendarWrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|