Commit b91fd49b749998d0a11f79afbb00962a2db81c1f
Committed by
GitHub
Merge pull request #2368 from SergioCrisostomo/fix-datepicker-test
fix date picker callback test
Showing
1 changed file
with
5 additions
and
4 deletions
Show diff stats
test/unit/specs/date-picker.spec.js
... | ... | @@ -122,15 +122,15 @@ describe('DatePicker.vue', () => { |
122 | 122 | it('should fire `on-change` when reseting value', done => { |
123 | 123 | const now = new Date(); |
124 | 124 | const nowDate = [now.getFullYear(), now.getMonth() + 1, now.getDate()].map(nr => (nr > 9 ? nr : '0' + nr)).join('-'); |
125 | - let callback; | |
125 | + let onChangeCalled = false; | |
126 | 126 | vm = createVue({ |
127 | - template: '<date-picker :value="date" type="date" @on-change="handleChange"></date-picker>', | |
127 | + template: '<date-picker :value="date" type="date" @on-change="onChange"></date-picker>', | |
128 | 128 | data(){ |
129 | 129 | return { date: now }; |
130 | 130 | }, |
131 | 131 | methods: { |
132 | - onChange(date) { | |
133 | - callback(date, this.date); | |
132 | + onChange() { | |
133 | + onChangeCalled = true; | |
134 | 134 | } |
135 | 135 | } |
136 | 136 | }); |
... | ... | @@ -143,6 +143,7 @@ describe('DatePicker.vue', () => { |
143 | 143 | picker.showClose = true; // to simulate mouseenter in the Input |
144 | 144 | picker.handleIconClick(); // reset the input value |
145 | 145 | vm.$nextTick(() => { |
146 | + expect(onChangeCalled).to.equal(true); | |
146 | 147 | expect(displayField.value).to.equal(''); |
147 | 148 | done(); |
148 | 149 | }); | ... | ... |