@@ -180,6 +180,56 @@ describe('test dateInput input behavior', () => {
180180 wrapper . unmount ( )
181181 } )
182182
183+ test . each ( [
184+ {
185+ type : 'date' ,
186+ modelValue : [ '2021-04-08' , '2021-04-10' ] ,
187+ input : '2021-04-12 ~ 2021-04-09' ,
188+ } ,
189+ {
190+ type : 'datetime' ,
191+ modelValue : [ '2021-04-08 09:00:00' , '2021-04-08 18:00:00' ] ,
192+ input : '2021-04-08 20:00:00 ~ 2021-04-08 10:00:00' ,
193+ } ,
194+ ] ) ( 'dateInput rejects a manually entered reversed $type range' , async ( { type, modelValue, input } ) => {
195+ const onUpdateModelValue = vi . fn ( )
196+ const wrapper = mount ( VarDateInput , {
197+ props : {
198+ type,
199+ range : true ,
200+ modelValue,
201+ 'onUpdate:modelValue' : onUpdateModelValue ,
202+ } ,
203+ } )
204+
205+ await triggerInput ( wrapper , input )
206+
207+ expect ( wrapper . find ( 'input' ) . element . value ) . toBe ( input )
208+ expect ( onUpdateModelValue ) . not . toHaveBeenCalled ( )
209+
210+ await wrapper . find ( 'input' ) . trigger ( 'change' )
211+ expect ( wrapper . find ( 'input' ) . element . value ) . toBe ( modelValue . join ( ' ~ ' ) )
212+
213+ wrapper . unmount ( )
214+ } )
215+
216+ test ( 'dateInput accepts a manually entered range with equal endpoints' , async ( ) => {
217+ const onUpdateModelValue = vi . fn ( )
218+ const wrapper = mount ( VarDateInput , {
219+ props : {
220+ range : true ,
221+ modelValue : [ ] ,
222+ 'onUpdate:modelValue' : onUpdateModelValue ,
223+ } ,
224+ } )
225+
226+ await triggerInput ( wrapper , '2021-04-08 ~ 2021-04-08' )
227+
228+ expect ( onUpdateModelValue ) . lastCalledWith ( [ '2021-04-08' , '2021-04-08' ] )
229+
230+ wrapper . unmount ( )
231+ } )
232+
183233 test ( 'dateInput validates allowedTimes with range positions on manual input' , async ( ) => {
184234 const onUpdateModelValue = vi . fn ( )
185235 const allowedTimes = vi . fn ( ( _date , position ) => ( {
0 commit comments