Commit 1239990c21b1376c1c23f380277575b8a2cba319
Committed by
GitHub
Merge pull request #1604 from SergioCrisostomo/2.0
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 | +}); | ... | ... |