fix specs, fix merge conflicts and cleanup
This commit is contained in:
parent
d9ff845f63
commit
5426dcf989
8 changed files with 36 additions and 17 deletions
5
package-lock.json
generated
5
package-lock.json
generated
|
@ -7169,6 +7169,11 @@
|
|||
"integrity": "sha1-8OgK4DmkvWVLXygfyT8EqRSn/M4=",
|
||||
"dev": true
|
||||
},
|
||||
"js-calendar": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/js-calendar/-/js-calendar-1.2.3.tgz",
|
||||
"integrity": "sha512-dAA1/Zbp4+c5E+ARCVTIuKepXsNLzSYfzvOimiYD4S5eeP9QuplSHLcdhfqFSwyM1o1u6ku6RRRCyaZ0YAjiBw=="
|
||||
},
|
||||
"js-tokens": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz",
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
"async-validator": "^1.8.2",
|
||||
"deepmerge": "^1.5.2",
|
||||
"element-resize-detector": "^1.1.13",
|
||||
"js-calendar": "^1.2.3",
|
||||
"lodash.throttle": "^4.1.1",
|
||||
"popper.js": "^0.6.4",
|
||||
"tinycolor2": "^1.4.1"
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
start: isRange && time === minDay,
|
||||
end: isRange && time === maxDay
|
||||
};
|
||||
}).cells.slice(8);
|
||||
}).cells;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
import {clearHours} from '../util';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
tableDate: {
|
||||
|
@ -36,7 +38,7 @@ export default {
|
|||
methods: {
|
||||
handleClick (cell) {
|
||||
if (cell.disabled) return;
|
||||
const newDate = cell.date;
|
||||
const newDate = new Date(clearHours(cell.date));
|
||||
|
||||
this.$emit('on-pick', newDate);
|
||||
this.$emit('on-pick-click');
|
||||
|
|
|
@ -219,7 +219,6 @@
|
|||
};
|
||||
},
|
||||
prevYear (panel) {
|
||||
console.log(this)
|
||||
const increment = this.currentView === 'year' ? -10 : -1;
|
||||
this.changePanelDate(panel, 'FullYear', increment);
|
||||
},
|
||||
|
|
|
@ -132,7 +132,7 @@
|
|||
|
||||
// set dateStart
|
||||
Object.keys(start).forEach(type => {
|
||||
dateStart[`set${capitalize(type)}`](start[type])
|
||||
dateStart[`set${capitalize(type)}`](start[type]);
|
||||
});
|
||||
|
||||
// set dateEnd
|
||||
|
|
|
@ -222,7 +222,6 @@ export const TYPE_VALUE_RESOLVER_MAP = {
|
|||
},
|
||||
multiple: {
|
||||
formatter: (value, format) => {
|
||||
console.log(value, format);
|
||||
return value.filter(Boolean).map(date => formatDate(date, format)).join(',');
|
||||
},
|
||||
parser: (text, format) => text.split(',').map(string => parseDate(string.trim(), format))
|
||||
|
|
|
@ -11,7 +11,7 @@ describe('DatePicker.vue', () => {
|
|||
<Date-Picker></Date-Picker>
|
||||
`);
|
||||
const picker = vm.$children[0];
|
||||
picker.showPicker();
|
||||
picker.$el.querySelector('input.ivu-input').focus();
|
||||
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 => {
|
||||
|
@ -20,7 +20,7 @@ describe('DatePicker.vue', () => {
|
|||
return !prevMonth && !nextMonth;
|
||||
});
|
||||
const today = new Date();
|
||||
const daysInCurrentMonth = new Date(today.getFullYear(), today.getMonth() + 1, 0).getDate();
|
||||
const daysInCurrentMonth = new Date(today.getFullYear(), today.getMonth(), 0).getDate();
|
||||
expect(daysInCurrentMonth).to.equal(calendarCells.length);
|
||||
done();
|
||||
});
|
||||
|
@ -32,7 +32,7 @@ describe('DatePicker.vue', () => {
|
|||
`);
|
||||
const picker = vm.$children[0];
|
||||
expect(picker.$children.length).to.equal(2);
|
||||
expect(Array.isArray(picker.currentValue)).to.equal(true);
|
||||
expect(Array.isArray(picker.internalValue)).to.equal(true);
|
||||
done();
|
||||
});
|
||||
|
||||
|
@ -61,10 +61,17 @@ describe('DatePicker.vue', () => {
|
|||
dayFive.setHours(0, 0, 0, 0);
|
||||
|
||||
// check pickers internal value
|
||||
const [startInternalValue, endInternalValue] = picker.currentValue; // Date Objects
|
||||
const [startInternalValue, endInternalValue] = picker.internalValue; // Date Objects
|
||||
expect(Math.abs(dayOne - startInternalValue)).to.equal(0);
|
||||
expect(Math.abs(dayFive - endInternalValue)).to.equal(0);
|
||||
|
||||
/*
|
||||
const [startInternalValue, endInternalValue] = picker.internalValue; // Date Objects
|
||||
expect(dateToString(dayOne)).to.equal(dateToString(startInternalValue));
|
||||
expect(dateToString(dayFive)).to.equal(dateToString(endInternalValue));
|
||||
|
||||
*/
|
||||
|
||||
// check pickers display value
|
||||
const [startDisplayValue, endDisplayValue] = displayField.value.split(' - ').map(stringToDate); // Date Objects
|
||||
expect(Math.abs(dayOne - startDisplayValue)).to.equal(0);
|
||||
|
@ -77,6 +84,7 @@ describe('DatePicker.vue', () => {
|
|||
});
|
||||
|
||||
it('should change type progamatically', done => {
|
||||
// https://jsfiddle.net/hq7cLz83/
|
||||
vm = createVue({
|
||||
template: '<Date-picker :type="dateType"></Date-picker>',
|
||||
data() {
|
||||
|
@ -94,9 +102,9 @@ describe('DatePicker.vue', () => {
|
|||
const monthPanel = panel.querySelector('.ivu-date-picker-cells-month');
|
||||
const yearPanel = panel.querySelector('.ivu-date-picker-cells-year');
|
||||
|
||||
expect(dayPanel.style.display).to.equal('none');
|
||||
expect(dayPanel).to.equal(null);
|
||||
expect(monthPanel.style.display).to.equal('');
|
||||
expect(yearPanel.style.display).to.equal('none');
|
||||
expect(yearPanel).to.equal(null);
|
||||
|
||||
expect(picker.type).to.equal('month');
|
||||
expect(picker.selectionMode).to.equal('month');
|
||||
|
@ -104,6 +112,11 @@ describe('DatePicker.vue', () => {
|
|||
vm.dateType = 'year';
|
||||
promissedTick(picker)
|
||||
.then(() => {
|
||||
const yearPanel = panel.querySelector('.ivu-date-picker-cells-year');
|
||||
const monthPanel = panel.querySelector('.ivu-date-picker-cells-month');
|
||||
expect(yearPanel.style.display).to.equal('');
|
||||
expect(monthPanel).to.equal(null);
|
||||
|
||||
expect(picker.type).to.equal('year');
|
||||
expect(picker.selectionMode).to.equal('year');
|
||||
|
||||
|
@ -112,10 +125,10 @@ describe('DatePicker.vue', () => {
|
|||
})
|
||||
.then(() => {
|
||||
expect(picker.type).to.equal('date');
|
||||
expect(picker.selectionMode).to.equal('day');
|
||||
expect(picker.selectionMode).to.equal('date');
|
||||
|
||||
done();
|
||||
});
|
||||
}).catch(err => console.log(err));
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -170,7 +183,7 @@ describe('DatePicker.vue', () => {
|
|||
clickableCells[firstDayInMonthIndex + 4].firstElementChild.click();
|
||||
vm.$nextTick(() => {
|
||||
// cache first values
|
||||
const [startInternalValue, endInternalValue] = picker.currentValue; // Date Objects
|
||||
const [startInternalValue, endInternalValue] = picker.internalValue; // Date Objects
|
||||
const [startDisplayValue, endDisplayValue] = displayField.value.split(' - ').map(stringToDate); // Date Objects
|
||||
|
||||
// clear picker
|
||||
|
@ -183,7 +196,7 @@ describe('DatePicker.vue', () => {
|
|||
|
||||
vm.$nextTick(() => {
|
||||
expect(picker.visible).to.equal(true);
|
||||
expect(JSON.stringify(picker.currentValue)).to.equal('[null,null]');
|
||||
expect(JSON.stringify(picker.internalValue)).to.equal('[null,null]');
|
||||
expect(displayField.value).to.equal('');
|
||||
|
||||
clickableCells[firstDayInMonthIndex].firstElementChild.click();
|
||||
|
@ -191,8 +204,8 @@ describe('DatePicker.vue', () => {
|
|||
clickableCells[firstDayInMonthIndex + 4].firstElementChild.click();
|
||||
vm.$nextTick(() => {
|
||||
// recheck internal values
|
||||
expect(Math.abs(picker.currentValue[0] - startInternalValue)).to.equal(0);
|
||||
expect(Math.abs(picker.currentValue[1] - endInternalValue)).to.equal(0);
|
||||
expect(Math.abs(picker.internalValue[0] - startInternalValue)).to.equal(0);
|
||||
expect(Math.abs(picker.internalValue[1] - endInternalValue)).to.equal(0);
|
||||
// recheck display value
|
||||
const [_startDisplayValue, _endDisplayValue] = displayField.value.split(' - ').map(stringToDate); // Date Objects
|
||||
expect(Math.abs(_startDisplayValue - startDisplayValue)).to.equal(0);
|
||||
|
|
Loading…
Add table
Reference in a new issue