2
0
mirror of https://github.com/tenrok/vue2-datepicker.git synced 2026-06-25 01:30:35 +03:00

fix: should return [null, null] when clear range

This commit is contained in:
mengxiong10
2019-11-12 13:03:22 +08:00
parent e4a5cedaa6
commit 635631fd12
2 changed files with 15 additions and 1 deletions
+14
View File
@@ -285,5 +285,19 @@ describe('DatePicker', () => {
clearButton.trigger('mousedown');
const emitted = wrapper.emitted();
expect(emitted.clear).toBeTruthy();
expect(emitted.input[0][0]).toBe(null);
});
it('feat: should emit [null, null] when clear range', () => {
wrapper = shallowMount(DatePicker, {
propsData: {
range: true,
value: [new Date(2019, 10, 9), new Date(2019, 11, 9)],
},
});
const clearButton = wrapper.find('.mx-icon-clear');
clearButton.trigger('mousedown');
const emitted = wrapper.emitted();
expect(emitted.input[0][0]).toEqual([null, null]);
});
});
+1 -1
View File
@@ -363,7 +363,7 @@ export default {
}
},
handleClear() {
this.emitValue(null);
this.emitValue(this.range ? [null, null] : null);
this.$emit('clear');
},
handleConfirmDate() {