Commit fd05bc44e0cca04c622b8dad6c9ab786cca137d1
1 parent
06b2a848
add basic DatePicker test
Showing
1 changed file
with
28 additions
and
0 deletions
Show diff stats
| 1 | +import { createVue, destroyVM } from '../util'; | ||
| 2 | + | ||
| 3 | +describe('DatePicker.vue', () => { | ||
| 4 | + let vm; | ||
| 5 | + afterEach(() => { | ||
| 6 | + destroyVM(vm); | ||
| 7 | + }); | ||
| 8 | + | ||
| 9 | + it('should create a DatePicker component and open the calendar with the current month', done => { | ||
| 10 | + vm = createVue(` | ||
| 11 | + <Date-Picker></Date-Picker> | ||
| 12 | + `); | ||
| 13 | + const picker = vm.$children[0]; | ||
| 14 | + picker.showPicker(); | ||
| 15 | + vm.$nextTick(() => { | ||
| 16 | + const calendarBody = vm.$el.querySelector('.ivu-picker-panel-body .ivu-date-picker-cells:first-of-type'); | ||
| 17 | + const calendarCells = [...calendarBody.querySelectorAll('.ivu-date-picker-cells-cell')].filter(el => { | ||
| 18 | + const prevMonth = el.classList.contains('ivu-date-picker-cells-cell-prev-month'); | ||
| 19 | + const nextMonth = el.classList.contains('ivu-date-picker-cells-cell-next-month'); | ||
| 20 | + return !prevMonth && !nextMonth; | ||
| 21 | + }); | ||
| 22 | + const today = new Date(); | ||
| 23 | + const daysInCurrentMonth = new Date(today.getFullYear(), today.getMonth() + 1, 0).getDate(); | ||
| 24 | + expect(daysInCurrentMonth).to.equal(calendarCells.length); | ||
| 25 | + done(); | ||
| 26 | + }); | ||
| 27 | + }); | ||
| 28 | +}); |