mirror of
https://gitee.com/ElemeFE/element.git
synced 2024-12-02 20:28:52 +08:00
test: fix broken date-picker default-value test
This commit is contained in:
parent
d35ae01042
commit
848346c954
@ -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', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user