@@ -35,12 +35,8 @@ describe('tooltip props', () => {
35
35
36
36
await userEvent . hover ( anchorElement )
37
37
38
- let tooltip = null
39
-
40
- await waitFor ( ( ) => {
41
- tooltip = screen . getByRole ( 'tooltip' )
42
- expect ( tooltip ) . toHaveAttribute ( 'style' )
43
- } )
38
+ const tooltip = await screen . findByRole ( 'tooltip' )
39
+ expect ( tooltip ) . toHaveAttribute ( 'style' )
44
40
45
41
expect ( tooltip ) . toBeInTheDocument ( )
46
42
expect ( container ) . toMatchSnapshot ( )
@@ -54,12 +50,8 @@ describe('tooltip props', () => {
54
50
55
51
await userEvent . hover ( anchorElement )
56
52
57
- let tooltip = null
58
-
59
- await waitFor ( ( ) => {
60
- tooltip = screen . getByRole ( 'tooltip' )
61
- expect ( tooltip ) . toHaveAttribute ( 'style' )
62
- } )
53
+ const tooltip = await screen . findByRole ( 'tooltip' )
54
+ expect ( tooltip ) . toHaveAttribute ( 'style' )
63
55
64
56
expect ( tooltip ) . toBeInTheDocument ( )
65
57
expect ( container ) . toMatchSnapshot ( )
@@ -71,12 +63,8 @@ describe('tooltip props', () => {
71
63
72
64
await userEvent . hover ( anchorElement )
73
65
74
- let tooltip = null
75
-
76
- await waitFor ( ( ) => {
77
- tooltip = screen . getByRole ( 'tooltip' )
78
- expect ( tooltip ) . toHaveAttribute ( 'style' )
79
- } )
66
+ const tooltip = await screen . findByRole ( 'tooltip' )
67
+ expect ( tooltip ) . toHaveAttribute ( 'style' )
80
68
81
69
expect ( tooltip ) . toBeInTheDocument ( )
82
70
expect ( container ) . toMatchSnapshot ( )
@@ -98,14 +86,10 @@ describe('tooltip props', () => {
98
86
99
87
await userEvent . hover ( anchorElement )
100
88
101
- let tooltip = null
102
- let button = null
89
+ const tooltip = await screen . findByRole ( 'tooltip' )
90
+ expect ( tooltip ) . toHaveAttribute ( 'style' )
103
91
104
- await waitFor ( ( ) => {
105
- tooltip = screen . getByRole ( 'tooltip' )
106
- button = screen . getByRole ( 'button' )
107
- expect ( tooltip ) . toHaveAttribute ( 'style' )
108
- } )
92
+ const button = await screen . findByRole ( 'button' )
109
93
110
94
await userEvent . click ( button )
111
95
@@ -123,22 +107,13 @@ describe('tooltip props', () => {
123
107
124
108
await userEvent . hover ( anchorElement )
125
109
126
- let tooltip = null
127
-
128
- await waitFor (
129
- ( ) => {
130
- expect ( screen . queryByRole ( 'tooltip' ) ) . not . toBeInTheDocument ( )
131
- } ,
132
- {
133
- timeout : 250 ,
134
- } ,
135
- )
136
-
137
110
await waitFor ( ( ) => {
138
- tooltip = screen . getByRole ( 'tooltip' )
139
- expect ( tooltip ) . toHaveAttribute ( 'style' )
111
+ expect ( screen . queryByRole ( 'tooltip' ) ) . not . toBeInTheDocument ( )
140
112
} )
141
113
114
+ const tooltip = await screen . findByRole ( 'tooltip' )
115
+ expect ( tooltip ) . toHaveAttribute ( 'style' )
116
+
142
117
expect ( tooltip ) . toBeInTheDocument ( )
143
118
expect ( container ) . toMatchSnapshot ( )
144
119
} )
@@ -151,15 +126,16 @@ describe('tooltip props', () => {
151
126
152
127
await userEvent . hover ( anchorElement )
153
128
154
- await waitFor ( ( ) => {
155
- expect ( screen . queryByRole ( 'tooltip' ) ) . toBeInTheDocument ( )
156
- } )
129
+ const tooltip = await screen . findByRole ( 'tooltip' )
130
+ expect ( tooltip ) . toHaveAttribute ( 'style' )
131
+
132
+ expect ( tooltip ) . toBeInTheDocument ( )
157
133
158
134
await userEvent . unhover ( anchorElement )
159
135
160
136
await waitFor (
161
137
( ) => {
162
- expect ( screen . queryByRole ( ' tooltip' ) ) . toBeInTheDocument ( )
138
+ expect ( tooltip ) . toBeInTheDocument ( )
163
139
} ,
164
140
{
165
141
timeout : 200 ,
@@ -168,7 +144,7 @@ describe('tooltip props', () => {
168
144
169
145
await waitFor (
170
146
( ) => {
171
- expect ( screen . queryByRole ( ' tooltip' ) ) . not . toBeInTheDocument ( )
147
+ expect ( tooltip ) . not . toBeInTheDocument ( )
172
148
} ,
173
149
{
174
150
timeout : 500 ,
@@ -186,12 +162,8 @@ describe('tooltip props', () => {
186
162
187
163
await userEvent . hover ( anchorElement )
188
164
189
- let tooltip = null
190
-
191
- await waitFor ( ( ) => {
192
- tooltip = screen . getByRole ( 'tooltip' )
193
- expect ( tooltip ) . toHaveAttribute ( 'style' )
194
- } )
165
+ const tooltip = await screen . findByRole ( 'tooltip' )
166
+ expect ( tooltip ) . toHaveAttribute ( 'style' )
195
167
196
168
expect ( tooltip ) . toBeInTheDocument ( )
197
169
expect ( container ) . toMatchSnapshot ( )
@@ -203,12 +175,8 @@ describe('tooltip props', () => {
203
175
204
176
await userEvent . hover ( anchorElement )
205
177
206
- let tooltip = null
207
-
208
- await waitFor ( ( ) => {
209
- tooltip = screen . getByRole ( 'tooltip' )
210
- expect ( tooltip ) . toHaveAttribute ( 'style' )
211
- } )
178
+ const tooltip = await screen . findByRole ( 'tooltip' )
179
+ expect ( tooltip ) . toHaveAttribute ( 'style' )
212
180
213
181
expect ( tooltip ) . toBeInTheDocument ( )
214
182
expect ( container ) . toMatchSnapshot ( )
0 commit comments