File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 1
1
import { mount } from '@vue/test-utils' ;
2
2
import TimePanel from '../src/time/time-panel' ;
3
+ import ListColumns from '../src/time/list-columns.vue' ;
3
4
4
5
let wrapper ;
5
6
@@ -96,4 +97,17 @@ describe('TimePanel', () => {
96
97
hour . trigger ( 'click' ) ;
97
98
expect ( wrapper . emitted ( ) . select ) . toBeUndefined ( ) ;
98
99
} ) ;
100
+
101
+ it ( 'fix: when the custom format pass into time panel' , ( ) => {
102
+ wrapper = mount ( TimePanel , {
103
+ propsData : {
104
+ value : new Date ( ) ,
105
+ format : { } ,
106
+ } ,
107
+ } ) ;
108
+ const cols = wrapper . find ( ListColumns ) ;
109
+ expect ( cols . props ( 'showHour' ) ) . toBe ( true ) ;
110
+ expect ( cols . props ( 'showMinute' ) ) . toBe ( true ) ;
111
+ expect ( cols . props ( 'showSecond' ) ) . toBe ( true ) ;
112
+ } ) ;
99
113
} ) ;
Original file line number Diff line number Diff line change 11
11
:date =" innerValue"
12
12
:get-classes =" getClasses"
13
13
:options =" timePickerOptions"
14
- :format =" format "
14
+ :format =" innerForamt "
15
15
@select =" handleSelect"
16
16
></list-options >
17
17
<list-columns
@@ -53,7 +53,6 @@ export default {
53
53
},
54
54
},
55
55
format: {
56
- type: String ,
57
56
default: ' HH:mm:ss' ,
58
57
},
59
58
timeTitleFormat: {
@@ -115,8 +114,11 @@ export default {
115
114
const date = new Date (this .innerValue );
116
115
return this .formatDate (date, titleFormat);
117
116
},
117
+ innerForamt () {
118
+ return typeof this .format === ' string' ? this .format : ' HH:mm:ss' ;
119
+ },
118
120
ShowHourMinuteSecondAMPM () {
119
- const { format } = this ;
121
+ const format = this . innerForamt ;
120
122
const defaultProps = {
121
123
showHour: / [HhKk] / .test (format),
122
124
showMinute: / m/ .test (format),
You can’t perform that action at this time.
0 commit comments