Commit 37fe6bb8f9c469bc187699911c4559ce4254ef03

Authored by Aresn
Committed by GitHub
2 parents 22c27b79 b1d124f6

Merge pull request #2361 from SergioCrisostomo/fix-2215

add test for #2215
Showing 1 changed file with 30 additions and 0 deletions   Show diff stats
test/unit/specs/date-picker.spec.js
... ... @@ -119,6 +119,36 @@ describe('DatePicker.vue', () => {
119 119 });
120 120 });
121 121  
  122 + it('should fire `on-change` when reseting value', done => {
  123 + const now = new Date();
  124 + const nowDate = [now.getFullYear(), now.getMonth() + 1, now.getDate()].map(nr => (nr > 9 ? nr : '0' + nr)).join('-');
  125 + let callback;
  126 + vm = createVue({
  127 + template: '<date-picker :value="date" type="date" @on-change="handleChange"></date-picker>',
  128 + data(){
  129 + return { date: now };
  130 + },
  131 + methods: {
  132 + onChange(date) {
  133 + callback(date, this.date);
  134 + }
  135 + }
  136 + });
  137 +
  138 + vm.$nextTick(() => {
  139 + const picker = vm.$children[0];
  140 + const displayField = vm.$el.querySelector('.ivu-input');
  141 + expect(displayField.value).to.equal(nowDate);
  142 +
  143 + picker.showClose = true; // to simulate mouseenter in the Input
  144 + picker.handleIconClick(); // reset the input value
  145 + vm.$nextTick(() => {
  146 + expect(displayField.value).to.equal('');
  147 + done();
  148 + });
  149 + });
  150 + });
  151 +
122 152 it('should have same behavior after a reset as before the reset', done => {
123 153 vm = createVue(`
124 154 <Date-picker type="datetimerange"></Date-picker>
... ...