Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit fe2e1ac

Browse files
committed
test(focus-lock): update focus-lock hook tests
1 parent fb153dc commit fe2e1ac

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

packages/c-focus-lock/tests/c-focus-lock.test.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { reactive } from 'vue'
22
import { render, screen, userEvent, waitMs } from '../../test-utils/src'
3-
import { CFocusLock, useFocusLock } from '../src'
3+
import { CFocusLock, useFocusLock, UseFocusLockOptions } from '../src'
44
import { CPortal } from '../../c-portal/src'
55

66
const onActivateMock = jest.fn()
@@ -35,7 +35,11 @@ const renderComponent = (props?: any) => {
3535
</div>
3636
`,
3737
setup() {
38-
const { lock } = useFocusLock()
38+
const { lock } = useFocusLock({
39+
immediate: true,
40+
onActivate: onActivateMock,
41+
onDeactivate: onDeactivateMock,
42+
})
3943

4044
return {
4145
lock,
@@ -46,7 +50,7 @@ const renderComponent = (props?: any) => {
4650
return render(base)
4751
}
4852

49-
it.skip('should focus first focusable child when mounted', async () => {
53+
it('should focus first focusable child when mounted', async () => {
5054
renderComponent()
5155

5256
/** We delay so that focus lock has time to activate */
@@ -57,7 +61,7 @@ it.skip('should focus first focusable child when mounted', async () => {
5761
expect(onActivateMock).toHaveBeenCalledTimes(1)
5862
})
5963

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 () => {
6165
renderComponent()
6266

6367
/** 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
7276
expect(onActivateMock).toHaveBeenCalledTimes(1)
7377
})
7478

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 () => {
7680
renderComponent({
7781
template: `
7882
<div :ref="lock" data-testid="focus-lock-container">
@@ -82,10 +86,11 @@ it.skip('should focus initialFocus element when initialFocus element is provided
8286
</div>
8387
`,
8488
setup() {
85-
const options = reactive({
89+
const options: UseFocusLockOptions = {
90+
immediate: true,
8691
onActivate: onActivateMock,
8792
onDeactivate: onDeactivateMock,
88-
})
93+
}
8994

9095
const { lock, initialFocus } = useFocusLock(options)
9196

@@ -104,7 +109,7 @@ it.skip('should focus initialFocus element when initialFocus element is provided
104109
expect(onActivateMock).toHaveBeenCalledTimes(1)
105110
})
106111

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 () => {
108113
renderComponent({
109114
template: `
110115
<div :ref="lock" data-testid="focus-lock-container">
@@ -116,7 +121,7 @@ it.skip('should deactivate focus-lock when clickOutsideDeactivates=`true` and cl
116121
`,
117122
setup() {
118123
const options = reactive({
119-
enabled: true,
124+
immediate: true,
120125
clickOutsideDeactivates: true,
121126
escapeDeactivates: false,
122127
onActivate: onActivateMock,

0 commit comments

Comments
 (0)