test: fix broken date-picker default-value test

This commit is contained in:
wacky6.AriesMBP 2017-09-18 04:17:21 +10:00 committed by 杨奕
parent d35ae01042
commit 848346c954

View File

@ -319,23 +319,11 @@ describe('DatePicker', () => {
});
it('default value', done => {
const toDateStr = date => {
let d = new Date(date);
return `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`;
};
let today = new Date();
let nextMonth = new Date(today);
nextMonth.setDate(1);
if (nextMonth.getMonth() === 12) {
nextMonth.setFullYear(today.getFullYear + 1);
nextMonth.setMonth(1);
} else {
nextMonth.setMonth(today.getMonth() + 1);
}
let nextMonthStr = toDateStr(nextMonth);
let defaultValue = '2000-01-01';
let expectValue = new Date(2000, 0, 1);
vm = createVue({
template: `<el-date-picker v-model="value" ref="compo" default-value="${nextMonthStr}" />`,
template: `<el-date-picker v-model="value" ref="compo" default-value="${defaultValue}" />`,
data() {
return {
value: ''
@ -350,10 +338,10 @@ describe('DatePicker', () => {
const $el = vm.$refs.compo.picker.$el;
$el.querySelector('td.current').click();
setTimeout(_ => {
expect(vm.value).to.equal(nextMonthStr);
});
expect(+vm.value).to.equal(+expectValue);
done();
});
}, 10);
}, 10);
});
describe('keydown', () => {