2
0
mirror of https://github.com/tenrok/vue2-datepicker.git synced 2026-06-12 12:42:28 +03:00

fix: clear event not triggering (#369)

This commit is contained in:
mengxiong10
2019-11-11 10:42:50 +08:00
parent deaf8ea28a
commit 06e158e20e
2 changed files with 19 additions and 1 deletions
+18 -1
View File
@@ -176,7 +176,12 @@ describe('DatePicker', () => {
expect(vm.text).toBe('2019/10/20');
vm.emitValue(emitValue);
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', () => {
@@ -269,4 +274,16 @@ describe('DatePicker', () => {
const popup = wrapper.find('.mx-datepicker-popup');
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();
});
});
+1
View File
@@ -364,6 +364,7 @@ export default {
},
handleClear() {
this.emitValue(null);
this.$emit('clear');
},
handleConfirmDate() {
const value = this.emitValue(this.currentValue);