mirror of
https://github.com/tenrok/vue2-datepicker.git
synced 2026-06-25 00:10:37 +03:00
fix: clear event not triggering (#369)
This commit is contained in:
@@ -176,7 +176,12 @@ describe('DatePicker', () => {
|
|||||||
expect(vm.text).toBe('2019/10/20');
|
expect(vm.text).toBe('2019/10/20');
|
||||||
vm.emitValue(emitValue);
|
vm.emitValue(emitValue);
|
||||||
const emitted = wrapper.emitted();
|
const emitted = wrapper.emitted();
|
||||||
expect(emitted.input).toEqual([[emitValue], ['2019/10/22'], [emitValue.getTime()], ['22/10/2019']]);
|
expect(emitted.input).toEqual([
|
||||||
|
[emitValue],
|
||||||
|
['2019/10/22'],
|
||||||
|
[emitValue.getTime()],
|
||||||
|
['22/10/2019'],
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('prop: shortcut', () => {
|
it('prop: shortcut', () => {
|
||||||
@@ -269,4 +274,16 @@ describe('DatePicker', () => {
|
|||||||
const popup = wrapper.find('.mx-datepicker-popup');
|
const popup = wrapper.find('.mx-datepicker-popup');
|
||||||
expect(popup.element.parentNode).toBe(document.body);
|
expect(popup.element.parentNode).toBe(document.body);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('feat: should emit clear event when click clear button', () => {
|
||||||
|
wrapper = shallowMount(DatePicker, {
|
||||||
|
propsData: {
|
||||||
|
value: new Date(2019, 10, 9),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const clearButton = wrapper.find('.mx-icon-clear');
|
||||||
|
clearButton.trigger('mousedown');
|
||||||
|
const emitted = wrapper.emitted();
|
||||||
|
expect(emitted.clear).toBeTruthy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -364,6 +364,7 @@ export default {
|
|||||||
},
|
},
|
||||||
handleClear() {
|
handleClear() {
|
||||||
this.emitValue(null);
|
this.emitValue(null);
|
||||||
|
this.$emit('clear');
|
||||||
},
|
},
|
||||||
handleConfirmDate() {
|
handleConfirmDate() {
|
||||||
const value = this.emitValue(this.currentValue);
|
const value = this.emitValue(this.currentValue);
|
||||||
|
|||||||
Reference in New Issue
Block a user