From fd05bc44e0cca04c622b8dad6c9ab786cca137d1 Mon Sep 17 00:00:00 2001 From: Sergio Crisostomo Date: Sun, 13 Aug 2017 10:17:13 +0200 Subject: [PATCH] add basic DatePicker test --- test/unit/specs/date-picker.spec.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+), 0 deletions(-) create mode 100644 test/unit/specs/date-picker.spec.js diff --git a/test/unit/specs/date-picker.spec.js b/test/unit/specs/date-picker.spec.js new file mode 100644 index 0000000..41b2371 --- /dev/null +++ b/test/unit/specs/date-picker.spec.js @@ -0,0 +1,28 @@ +import { createVue, destroyVM } from '../util'; + +describe('DatePicker.vue', () => { + let vm; + afterEach(() => { + destroyVM(vm); + }); + + it('should create a DatePicker component and open the calendar with the current month', done => { + vm = createVue(` + + `); + const picker = vm.$children[0]; + picker.showPicker(); + vm.$nextTick(() => { + const calendarBody = vm.$el.querySelector('.ivu-picker-panel-body .ivu-date-picker-cells:first-of-type'); + const calendarCells = [...calendarBody.querySelectorAll('.ivu-date-picker-cells-cell')].filter(el => { + const prevMonth = el.classList.contains('ivu-date-picker-cells-cell-prev-month'); + const nextMonth = el.classList.contains('ivu-date-picker-cells-cell-next-month'); + return !prevMonth && !nextMonth; + }); + const today = new Date(); + const daysInCurrentMonth = new Date(today.getFullYear(), today.getMonth() + 1, 0).getDate(); + expect(daysInCurrentMonth).to.equal(calendarCells.length); + done(); + }); + }); +}); -- libgit2 0.21.4