Skip to content

Commit

Permalink
fix: should click twice to open popup in mobile (#725)
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxiong10 committed Dec 1, 2022
1 parent 97afac8 commit 375edbb
Show file tree
Hide file tree
Showing 5 changed files with 33,323 additions and 15,059 deletions.
5 changes: 0 additions & 5 deletions __test__/__snapshots__/date-picker.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ exports[`DatePicker prop: editable 1`] = `
readonly="readonly"
type="text"
/>
<i
class="mx-icon-clear"
>
<anonymous-stub />
</i>
<i
class="mx-icon-calendar"
>
Expand Down
13 changes: 8 additions & 5 deletions __test__/date-picker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('DatePicker', () => {
expect(wrapper.find('.mx-datepicker-popup').exists()).toBe(false);
// expect click input should show the popup
const input = wrapper.find('input');
await input.trigger('mousedown');
await input.trigger('click');
expect(wrapper.find('.mx-datepicker-popup').exists()).toBe(true);
// expect click out side should hide the popup
const bodyWrapper = createWrapper(document.body);
Expand Down Expand Up @@ -296,28 +296,31 @@ describe('DatePicker', () => {
expect(popup.element.parentNode).toBe(document.body);
});

it('feat: should emit clear event when click clear button', () => {
it('feat: should emit clear event when click clear button', async () => {
wrapper = shallowMount(DatePicker, {
propsData: {
value: new Date(2019, 10, 9),
},
});
await wrapper.find('.mx-input-wrapper').trigger('mouseenter');
const clearButton = wrapper.find('.mx-icon-clear');
clearButton.trigger('mousedown');

clearButton.trigger('click');
const emitted = wrapper.emitted();
expect(emitted.clear).toBeTruthy();
expect(emitted.input[0][0]).toBe(null);
});

it('feat: should emit [null, null] when clear range', () => {
it('feat: should emit [null, null] when clear range', async () => {
wrapper = shallowMount(DatePicker, {
propsData: {
range: true,
value: [new Date(2019, 10, 9), new Date(2019, 11, 9)],
},
});
await wrapper.find('.mx-input-wrapper').trigger('mouseenter');
const clearButton = wrapper.find('.mx-icon-clear');
clearButton.trigger('mousedown');
clearButton.trigger('click');
const emitted = wrapper.emitted();
expect(emitted.input[0][0]).toEqual([null, null]);
});
Expand Down
Loading

0 comments on commit 375edbb

Please sign in to comment.