mirror of
https://github.com/tenrok/vue2-datepicker.git
synced 2026-06-23 13:00:35 +03:00
fix: when custom formatting causes the time-panel error (#377)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { mount } from '@vue/test-utils';
|
import { mount } from '@vue/test-utils';
|
||||||
import TimePanel from '../src/time/time-panel';
|
import TimePanel from '../src/time/time-panel';
|
||||||
|
import ListColumns from '../src/time/list-columns.vue';
|
||||||
|
|
||||||
let wrapper;
|
let wrapper;
|
||||||
|
|
||||||
@@ -96,4 +97,17 @@ describe('TimePanel', () => {
|
|||||||
hour.trigger('click');
|
hour.trigger('click');
|
||||||
expect(wrapper.emitted().select).toBeUndefined();
|
expect(wrapper.emitted().select).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('fix: when the custom format pass into time panel', () => {
|
||||||
|
wrapper = mount(TimePanel, {
|
||||||
|
propsData: {
|
||||||
|
value: new Date(),
|
||||||
|
format: {},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const cols = wrapper.find(ListColumns);
|
||||||
|
expect(cols.props('showHour')).toBe(true);
|
||||||
|
expect(cols.props('showMinute')).toBe(true);
|
||||||
|
expect(cols.props('showSecond')).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
:date="innerValue"
|
:date="innerValue"
|
||||||
:get-classes="getClasses"
|
:get-classes="getClasses"
|
||||||
:options="timePickerOptions"
|
:options="timePickerOptions"
|
||||||
:format="format"
|
:format="innerForamt"
|
||||||
@select="handleSelect"
|
@select="handleSelect"
|
||||||
></list-options>
|
></list-options>
|
||||||
<list-columns
|
<list-columns
|
||||||
@@ -53,7 +53,6 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
format: {
|
format: {
|
||||||
type: String,
|
|
||||||
default: 'HH:mm:ss',
|
default: 'HH:mm:ss',
|
||||||
},
|
},
|
||||||
timeTitleFormat: {
|
timeTitleFormat: {
|
||||||
@@ -115,8 +114,11 @@ export default {
|
|||||||
const date = new Date(this.innerValue);
|
const date = new Date(this.innerValue);
|
||||||
return this.formatDate(date, titleFormat);
|
return this.formatDate(date, titleFormat);
|
||||||
},
|
},
|
||||||
|
innerForamt() {
|
||||||
|
return typeof this.format === 'string' ? this.format : 'HH:mm:ss';
|
||||||
|
},
|
||||||
ShowHourMinuteSecondAMPM() {
|
ShowHourMinuteSecondAMPM() {
|
||||||
const { format } = this;
|
const format = this.innerForamt;
|
||||||
const defaultProps = {
|
const defaultProps = {
|
||||||
showHour: /[HhKk]/.test(format),
|
showHour: /[HhKk]/.test(format),
|
||||||
showMinute: /m/.test(format),
|
showMinute: /m/.test(format),
|
||||||
|
|||||||
Reference in New Issue
Block a user