2
0
mirror of https://github.com/tenrok/vue2-datepicker.git synced 2026-06-18 21:40:36 +03:00

feat: ignore whitespace around separator on manual range input (#416)

This commit is contained in:
mengxiong10
2020-03-06 16:57:06 +08:00
parent 17d2262c59
commit 376a7ef412
2 changed files with 22 additions and 3 deletions
+20 -1
View File
@@ -355,8 +355,8 @@ describe('DatePicker', () => {
it('should emit pick event on first click', () => {
wrapper = mount(DatePicker, {
range: true,
propsData: {
range: true,
open: true,
defaultValue: new Date(2019, 9, 1),
},
@@ -365,4 +365,23 @@ describe('DatePicker', () => {
td.trigger('click');
expect(wrapper.emitted().pick[0][0]).toEqual(new Date(2019, 8, 29));
});
it('Ignore whitespace around separator on manual range input', () => {
const rangeSeparator = ' ~ ';
const text = '2020-02-12';
wrapper = mount(DatePicker, {
propsData: {
range: true,
rangeSeparator: ' ~ ',
valueType: 'format',
},
});
const input = wrapper.find('input');
input.setValue(`${text} ${rangeSeparator} ${text}`);
input.trigger('change');
input.setValue(`${text}${rangeSeparator.trim()}${text}`);
input.trigger('change');
expect(wrapper.emitted().input).toEqual([[[text, text]], [[text, text]]]);
});
});