@@ -5,22 +5,25 @@ import { describe, expect, it, vi } from 'vitest';
5
5
import { OverlayProvider } from './context/provider' ;
6
6
import { overlay } from './event' ;
7
7
8
- const wrapper = ( { children } : PropsWithChildren ) => < OverlayProvider > { children } </ OverlayProvider > ;
8
+ function wrapper ( { children } : PropsWithChildren ) {
9
+ return < OverlayProvider > { children } </ OverlayProvider > ;
10
+ }
9
11
10
12
/**
11
13
*
12
14
* @description Utility functions to perform render and userEvent.setup
13
15
*/
14
- const renderWithUser = < T extends JSX . Element > ( Component : T , options ?: Parameters < typeof render > [ 1 ] ) => {
16
+ function renderWithUser < T extends JSX . Element > ( component : T , options ?: Parameters < typeof render > [ 1 ] ) {
15
17
const user = userEvent . setup ( ) ;
16
- return { ...render ( Component , { wrapper, ...options } ) , user } ;
17
- } ;
18
+
19
+ return { ...render ( component , { wrapper, ...options } ) , user } ;
20
+ }
18
21
19
22
describe ( 'overlay object' , ( ) => {
20
23
it ( 'should be able to close an open overlay using overlay.unmount' , async ( ) => {
21
24
const overlayDialogContent = 'context-modal-overlay-dialog-content' ;
22
25
23
- const Component = ( ) => {
26
+ function Component ( ) {
24
27
useEffect ( ( ) => {
25
28
overlay . open ( ( { overlayId } ) => {
26
29
return (
@@ -34,8 +37,9 @@ describe('overlay object', () => {
34
37
) ;
35
38
} ) ;
36
39
} , [ ] ) ;
40
+
37
41
return < div > Empty</ div > ;
38
- } ;
42
+ }
39
43
40
44
const { user } = renderWithUser ( < Component /> ) ;
41
45
@@ -50,7 +54,7 @@ describe('overlay object', () => {
50
54
const testContent3 = 'context-modal-test-content-3' ;
51
55
const testContent4 = 'context-modal-test-content-4' ;
52
56
53
- const Component = ( ) => {
57
+ function Component ( ) {
54
58
useEffect ( ( ) => {
55
59
overlay . open ( ( ) => {
56
60
return < p > { testContent1 } </ p > ;
@@ -67,7 +71,7 @@ describe('overlay object', () => {
67
71
} , [ ] ) ;
68
72
69
73
return < div > Empty</ div > ;
70
- } ;
74
+ }
71
75
72
76
render ( < Component /> , { wrapper } ) ;
73
77
expect ( screen . queryByText ( testContent1 ) ) . toBeInTheDocument ( ) ;
@@ -81,7 +85,7 @@ describe('overlay object', () => {
81
85
const overlayTriggerContent = 'context-modal-overlay-trigger-content' ;
82
86
const mockFn = vi . fn ( ) ;
83
87
84
- const Component = ( ) => {
88
+ function Component ( ) {
85
89
return (
86
90
< button
87
91
onClick = { async ( ) => {
@@ -97,7 +101,7 @@ describe('overlay object', () => {
97
101
{ overlayTriggerContent }
98
102
</ button >
99
103
) ;
100
- } ;
104
+ }
101
105
102
106
const { user } = renderWithUser ( < Component /> ) ;
103
107
@@ -114,7 +118,7 @@ describe('overlay object', () => {
114
118
const overlayTriggerContent = 'context-modal-test-content' ;
115
119
const overlayDialogContent = 'context-modal-dialog-content' ;
116
120
117
- const Component = ( ) => {
121
+ function Component ( ) {
118
122
return (
119
123
< button
120
124
onClick = { async ( ) => {
@@ -126,7 +130,7 @@ describe('overlay object', () => {
126
130
{ overlayTriggerContent }
127
131
</ button >
128
132
) ;
129
- } ;
133
+ }
130
134
131
135
const { user } = renderWithUser ( < Component /> , { wrapper } ) ;
132
136
0 commit comments