@@ -157,24 +157,52 @@ describe('VNumberInput', () => {
157157 } )
158158
159159 describe ( 'native number input quirks' , ( ) => {
160- it ( 'should not bypass min ' , async ( ) => {
160+ it ( 'should auto-clamp after interaction ' , async ( ) => {
161161 const model = ref ( 1 )
162162 render ( ( ) =>
163163 < VNumberInput min = { 5 } max = { 15 } v-model = { model . value } />
164164 )
165165
166+ await expect . element ( screen . getByCSS ( 'input' ) ) . toHaveValue ( '1' )
167+ expect ( model . value ) . toBe ( 1 )
168+
169+ await userEvent . click ( screen . getByCSS ( 'input' ) )
170+ await userEvent . tab ( )
171+
166172 await expect . element ( screen . getByCSS ( 'input' ) ) . toHaveValue ( '5' )
167173 expect ( model . value ) . toBe ( 5 )
168174 } )
169175
170- it ( 'should not bypass max ' , async ( ) => {
176+ it ( 'should apply increments within the range ' , async ( ) => {
171177 const model = ref ( 20 )
172178 render ( ( ) =>
173179 < VNumberInput min = { 5 } max = { 15 } v-model = { model . value } />
174180 )
175181
176- await expect . element ( screen . getByCSS ( 'input' ) ) . toHaveValue ( '15' )
177- expect ( model . value ) . toBe ( 15 )
182+ await expect . element ( screen . getByCSS ( 'input' ) ) . toHaveValue ( '20' )
183+ expect ( model . value ) . toBe ( 20 )
184+
185+ await userEvent . click ( screen . getByCSS ( 'input' ) )
186+ await userEvent . keyboard ( '{arrowDown}' )
187+
188+ await expect . element ( screen . getByCSS ( 'input' ) ) . toHaveValue ( '14' )
189+ expect ( model . value ) . toBe ( 14 )
190+ } )
191+
192+ it ( 'should auto-correct when incrementing against the limit' , async ( ) => {
193+ const model = ref ( - 33 )
194+ render ( ( ) =>
195+ < VNumberInput min = { - 10 } max = { 20 } v-model = { model . value } precision = { 2 } step = { 0.5 } />
196+ )
197+
198+ await expect . element ( screen . getByCSS ( 'input' ) ) . toHaveValue ( '-33.00' )
199+ expect ( model . value ) . toBe ( - 33 )
200+
201+ await userEvent . click ( screen . getByCSS ( 'input' ) )
202+ await userEvent . keyboard ( '{arrowDown}' )
203+
204+ await expect . element ( screen . getByCSS ( 'input' ) ) . toHaveValue ( '-10' )
205+ expect ( model . value ) . toBe ( - 10 )
178206 } )
179207
180208 it ( 'supports decimal step' , async ( ) => {
0 commit comments