1
1
import { reactive } from 'vue'
2
2
import { render , screen , userEvent , waitMs } from '../../test-utils/src'
3
- import { CFocusLock , useFocusLock } from '../src'
3
+ import { CFocusLock , useFocusLock , UseFocusLockOptions } from '../src'
4
4
import { CPortal } from '../../c-portal/src'
5
5
6
6
const onActivateMock = jest . fn ( )
@@ -35,7 +35,11 @@ const renderComponent = (props?: any) => {
35
35
</div>
36
36
` ,
37
37
setup ( ) {
38
- const { lock } = useFocusLock ( )
38
+ const { lock } = useFocusLock ( {
39
+ immediate : true ,
40
+ onActivate : onActivateMock ,
41
+ onDeactivate : onDeactivateMock ,
42
+ } )
39
43
40
44
return {
41
45
lock,
@@ -46,7 +50,7 @@ const renderComponent = (props?: any) => {
46
50
return render ( base )
47
51
}
48
52
49
- it . skip ( 'should focus first focusable child when mounted' , async ( ) => {
53
+ it ( 'should focus first focusable child when mounted' , async ( ) => {
50
54
renderComponent ( )
51
55
52
56
/** We delay so that focus lock has time to activate */
@@ -57,7 +61,7 @@ it.skip('should focus first focusable child when mounted', async () => {
57
61
expect ( onActivateMock ) . toHaveBeenCalledTimes ( 1 )
58
62
} )
59
63
60
- it . skip ( 'should focus first focusable child when after tab cycle is complete' , async ( ) => {
64
+ it ( 'should focus first focusable child when after tab cycle is complete' , async ( ) => {
61
65
renderComponent ( )
62
66
63
67
/** We delay so that focus lock has time to activate */
@@ -72,7 +76,7 @@ it.skip('should focus first focusable child when after tab cycle is complete', a
72
76
expect ( onActivateMock ) . toHaveBeenCalledTimes ( 1 )
73
77
} )
74
78
75
- it . skip ( 'should focus initialFocus element when initialFocus element is provided' , async ( ) => {
79
+ it ( 'should focus initialFocus element when initialFocus element is provided' , async ( ) => {
76
80
renderComponent ( {
77
81
template : `
78
82
<div :ref="lock" data-testid="focus-lock-container">
@@ -82,10 +86,11 @@ it.skip('should focus initialFocus element when initialFocus element is provided
82
86
</div>
83
87
` ,
84
88
setup ( ) {
85
- const options = reactive ( {
89
+ const options : UseFocusLockOptions = {
90
+ immediate : true ,
86
91
onActivate : onActivateMock ,
87
92
onDeactivate : onDeactivateMock ,
88
- } )
93
+ }
89
94
90
95
const { lock, initialFocus } = useFocusLock ( options )
91
96
@@ -104,7 +109,7 @@ it.skip('should focus initialFocus element when initialFocus element is provided
104
109
expect ( onActivateMock ) . toHaveBeenCalledTimes ( 1 )
105
110
} )
106
111
107
- it . skip ( 'should deactivate focus-lock when clickOutsideDeactivates=`true` and click event happens outside focus lock' , async ( ) => {
112
+ it ( 'should deactivate focus-lock when clickOutsideDeactivates=`true` and click event happens outside focus lock' , async ( ) => {
108
113
renderComponent ( {
109
114
template : `
110
115
<div :ref="lock" data-testid="focus-lock-container">
@@ -116,7 +121,7 @@ it.skip('should deactivate focus-lock when clickOutsideDeactivates=`true` and cl
116
121
` ,
117
122
setup ( ) {
118
123
const options = reactive ( {
119
- enabled : true ,
124
+ immediate : true ,
120
125
clickOutsideDeactivates : true ,
121
126
escapeDeactivates : false ,
122
127
onActivate : onActivateMock ,
0 commit comments