Skip to content

Commit

Permalink
fix: should return [null, null] when clear range
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxiong10 committed Nov 12, 2019
1 parent e4a5ced commit 635631f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions __test__/date-picker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
});
});
2 changes: 1 addition & 1 deletion src/date-picker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ export default {
}
},
handleClear() {
this.emitValue(null);
this.emitValue(this.range ? [null, null] : null);
this.$emit('clear');
},
handleConfirmDate() {
Expand Down

0 comments on commit 635631f

Please sign in to comment.