File tree Expand file tree Collapse file tree 4 files changed +13
-3
lines changed Expand file tree Collapse file tree 4 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 1+ import InputNumber from '..'
2+ import focusTest from '../../../tests/shared/focusTest'
3+
4+ focusTest ( InputNumber )
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ export const InputNumberProps = {
2525 name : PropTypes . string ,
2626 id : PropTypes . string ,
2727 precision : PropTypes . number ,
28+ autoFocus : PropTypes . bool ,
2829}
2930
3031export default {
Original file line number Diff line number Diff line change @@ -105,6 +105,9 @@ export default {
105105 } ,
106106 mounted ( ) {
107107 this . $nextTick ( ( ) => {
108+ if ( this . autoFocus && ! this . disabled ) {
109+ this . focus ( )
110+ }
108111 this . updatedFunc ( )
109112 } )
110113 } ,
@@ -571,7 +574,6 @@ export default {
571574 onBlur = { this . onBlur }
572575 onKeydown = { editable ? this . onKeyDown : noop }
573576 onKeyup = { editable ? this . onKeyUp : noop }
574- autoFocus = { this . autoFocus }
575577 maxLength = { this . maxLength }
576578 readOnly = { this . readOnly }
577579 disabled = { this . disabled }
Original file line number Diff line number Diff line change 11import { mount } from '@vue/test-utils'
2+ import { asyncExpect } from '../utils'
23
34export default function focusTest ( Component ) {
45 describe ( 'focus and blur' , ( ) => {
@@ -22,7 +23,7 @@ export default function focusTest (Component) {
2223 expect ( handleFocus ) . toBeCalled ( )
2324 } )
2425
25- it ( 'blur() and onBlur' , ( ) => {
26+ it ( 'blur() and onBlur' , async ( ) => {
2627 const handleBlur = jest . fn ( )
2728 const wrapper = mount ( {
2829 render ( h ) {
@@ -32,7 +33,9 @@ export default function focusTest (Component) {
3233 wrapper . vm . $refs . component . focus ( )
3334 wrapper . vm . $refs . component . blur ( )
3435 jest . runAllTimers ( )
35- expect ( handleBlur ) . toBeCalled ( )
36+ await asyncExpect ( ( ) => {
37+ expect ( handleBlur ) . toBeCalled ( )
38+ } )
3639 } )
3740
3841 it ( 'autoFocus' , ( done ) => {
You can’t perform that action at this time.
0 commit comments