2
0
mirror of https://github.com/tenrok/vue2-datepicker.git synced 2026-06-20 15:40:36 +03:00

feat: default-value supports Array for range (#395)

This commit is contained in:
xiemx
2019-12-16 18:13:08 +08:00
parent c8f7122b63
commit b33c9b8f19
9 changed files with 46 additions and 14 deletions
+13
View File
@@ -76,4 +76,17 @@ describe('CalendarRange', () => {
expect(startPanel.vm.partialUpdate).toBe(false);
expect(endPanel.vm.partialUpdate).toBe(false);
});
it('supports defaultValue is Array', () => {
wrapper = mount(CalendarRange, {
propsData: {
defaultValue: [new Date(2019, 9, 1), new Date(2019, 11, 1)],
},
});
const panels = wrapper.findAll(CalendarPanel);
const startPanel = panels.at(0);
const endPanel = panels.at(1);
expect(startPanel.vm.calendarMonth).toBe(9);
expect(endPanel.vm.calendarMonth).toBe(11);
});
});
+3 -3
View File
@@ -47,7 +47,7 @@ describe('DatetimeRange', () => {
wrapper = mount(DatetimeRange, {
sync: false,
propsData: {
defaultValue: new Date(2019, 9, 1),
defaultValue: [new Date(2019, 9, 1), new Date(2019, 9, 1, 12)],
disabledDate,
disabledTime,
},
@@ -59,11 +59,11 @@ describe('DatetimeRange', () => {
expect(wrapper.emitted().select).toBeUndefined();
const timeTitle = wrapper.find('.mx-time-header-title');
expect(timeTitle.text()).toBe('2019-10-02');
const defaultValue = new Date(2019, 9, 2, 12);
const defaultValue = [new Date(2019, 9, 2, 12), new Date(2019, 9, 2, 12)];
wrapper.setProps({ defaultValue });
td.trigger('click');
td.trigger('click');
await flushPromises();
expect(wrapper.emitted().select[0][0]).toEqual([defaultValue, defaultValue]);
expect(wrapper.emitted().select[0][0]).toEqual(defaultValue);
});
});
+11
View File
@@ -33,4 +33,15 @@ describe('TimeRange', () => {
new Date(2019, 9, 4, 19, 30, 0),
]);
});
it('supports defaultValue is Array', () => {
wrapper = mount(TimeRange, {
propsData: {
defaultValue: [new Date(2019, 9, 1, 10), new Date(2019, 11, 1, 12)],
},
});
const actived = wrapper.findAll('.active');
expect(actived.at(0).text()).toBe('10');
expect(actived.at(3).text()).toBe('12');
});
});