Merge pull request #1604 from SergioCrisostomo/2.0
add basic DatePicker test
This commit is contained in:
commit
1239990c21
1 changed files with 28 additions and 0 deletions
28
test/unit/specs/date-picker.spec.js
Normal file
28
test/unit/specs/date-picker.spec.js
Normal file
|
@ -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(`
|
||||
<Date-Picker></Date-Picker>
|
||||
`);
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Reference in a new issue