@@ -35,12 +35,8 @@ describe('tooltip props', () => {
3535
3636 await userEvent . hover ( anchorElement )
3737
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' )
4440
4541 expect ( tooltip ) . toBeInTheDocument ( )
4642 expect ( container ) . toMatchSnapshot ( )
@@ -54,12 +50,8 @@ describe('tooltip props', () => {
5450
5551 await userEvent . hover ( anchorElement )
5652
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' )
6355
6456 expect ( tooltip ) . toBeInTheDocument ( )
6557 expect ( container ) . toMatchSnapshot ( )
@@ -71,12 +63,8 @@ describe('tooltip props', () => {
7163
7264 await userEvent . hover ( anchorElement )
7365
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' )
8068
8169 expect ( tooltip ) . toBeInTheDocument ( )
8270 expect ( container ) . toMatchSnapshot ( )
@@ -98,14 +86,10 @@ describe('tooltip props', () => {
9886
9987 await userEvent . hover ( anchorElement )
10088
101- let tooltip = null
102- let button = null
89+ const tooltip = await screen . findByRole ( 'tooltip' )
90+ expect ( tooltip ) . toHaveAttribute ( 'style' )
10391
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' )
10993
11094 await userEvent . click ( button )
11195
@@ -123,22 +107,13 @@ describe('tooltip props', () => {
123107
124108 await userEvent . hover ( anchorElement )
125109
126- let tooltip = null
127-
128- await waitFor (
129- ( ) => {
130- expect ( screen . queryByRole ( 'tooltip' ) ) . not . toBeInTheDocument ( )
131- } ,
132- {
133- timeout : 250 ,
134- } ,
135- )
136-
137110 await waitFor ( ( ) => {
138- tooltip = screen . getByRole ( 'tooltip' )
139- expect ( tooltip ) . toHaveAttribute ( 'style' )
111+ expect ( screen . queryByRole ( 'tooltip' ) ) . not . toBeInTheDocument ( )
140112 } )
141113
114+ const tooltip = await screen . findByRole ( 'tooltip' )
115+ expect ( tooltip ) . toHaveAttribute ( 'style' )
116+
142117 expect ( tooltip ) . toBeInTheDocument ( )
143118 expect ( container ) . toMatchSnapshot ( )
144119 } )
@@ -151,15 +126,16 @@ describe('tooltip props', () => {
151126
152127 await userEvent . hover ( anchorElement )
153128
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 ( )
157133
158134 await userEvent . unhover ( anchorElement )
159135
160136 await waitFor (
161137 ( ) => {
162- expect ( screen . queryByRole ( ' tooltip' ) ) . toBeInTheDocument ( )
138+ expect ( tooltip ) . toBeInTheDocument ( )
163139 } ,
164140 {
165141 timeout : 200 ,
@@ -168,7 +144,7 @@ describe('tooltip props', () => {
168144
169145 await waitFor (
170146 ( ) => {
171- expect ( screen . queryByRole ( ' tooltip' ) ) . not . toBeInTheDocument ( )
147+ expect ( tooltip ) . not . toBeInTheDocument ( )
172148 } ,
173149 {
174150 timeout : 500 ,
@@ -186,12 +162,8 @@ describe('tooltip props', () => {
186162
187163 await userEvent . hover ( anchorElement )
188164
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' )
195167
196168 expect ( tooltip ) . toBeInTheDocument ( )
197169 expect ( container ) . toMatchSnapshot ( )
@@ -203,12 +175,8 @@ describe('tooltip props', () => {
203175
204176 await userEvent . hover ( anchorElement )
205177
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' )
212180
213181 expect ( tooltip ) . toBeInTheDocument ( )
214182 expect ( container ) . toMatchSnapshot ( )
0 commit comments