2
0
mirror of https://github.com/tenrok/vue2-datepicker.git synced 2026-06-21 05:20:35 +03:00

fix: value entered manually in disabled range should be invalid (#508)

This commit is contained in:
mengxiong10
2020-08-07 16:42:38 +08:00
parent 0dc1167d60
commit 1bca35bd74
2 changed files with 34 additions and 1 deletions
+20
View File
@@ -418,4 +418,24 @@ describe('DatePicker', () => {
});
expect(vm.validMultipleType).toBe(false);
});
it('If the value entered manually is in the disabled range should be invalid', () => {
const someday = new Date(2020, 6, 1);
wrapper = shallowMount(DatePicker, {
format: 'YYYY-MM-DD',
propsData: {
disabledDate: date => {
return date < someday;
},
},
});
const textInput = wrapper.find('input');
textInput.setValue('2020-08-01');
textInput.trigger('change');
expect(wrapper.emitted().input[0][0]).toEqual(new Date(2020, 7, 1));
textInput.setValue('2020-05-01');
textInput.trigger('change');
expect(wrapper.emitted().input[1]).toBe(undefined);
expect(wrapper.emitted()['input-error'][0][0]).toBe('2020-05-01');
});
});