@@ -220,10 +220,14 @@ describe('UUIToastNotificationElement', () => {
220
220
221
221
element . pauseAutoClose ( ) ;
222
222
223
- await sleep ( 600 ) ; // enough time for opening animation to be done.
223
+ // Wait for OPENED event
224
+ const openedListener = oneEvent ( element , UUIToastNotificationEvent . OPENED ) ;
225
+ const openedEvent = await openedListener ;
226
+ expect ( openedEvent ) . to . exist ;
227
+ expect ( openedEvent . type ) . to . equal ( UUIToastNotificationEvent . OPENED ) ;
224
228
225
229
element . resumeAutoClose ( ) ;
226
- expect ( element . open ) . to . be . true ;
230
+ expect ( element . open , 'Element should still be open immediately after resuming' ) . to . be . true ;
227
231
228
232
const closeListener = oneEvent (
229
233
element ,
@@ -251,7 +255,12 @@ describe('UUIToastNotificationElement', () => {
251
255
it ( 'clicking on the close-button did close' , async ( ) => {
252
256
element . open = true ;
253
257
254
- await sleep ( 100 ) ; // wait a bit.
258
+ // Wait for OPENED event
259
+ const openedListener = oneEvent ( element , UUIToastNotificationEvent . OPENED ) ;
260
+ const openedEvent = await openedListener ;
261
+ expect ( openedEvent ) . to . exist ;
262
+ expect ( openedEvent . type ) . to . equal ( UUIToastNotificationEvent . OPENED ) ;
263
+
255
264
expect ( element . open ) . to . be . true ;
256
265
257
266
const closeButton = element . shadowRoot ! . querySelector (
@@ -267,7 +276,12 @@ describe('UUIToastNotificationElement', () => {
267
276
it ( 'pressing esc when focus did close' , async ( ) => {
268
277
element . open = true ;
269
278
270
- await sleep ( 100 ) ; // wait a bit.
279
+ // Wait for OPENED event
280
+ const openedListener = oneEvent ( element , UUIToastNotificationEvent . OPENED ) ;
281
+ const openedEvent = await openedListener ;
282
+ expect ( openedEvent ) . to . exist ;
283
+ expect ( openedEvent . type ) . to . equal ( UUIToastNotificationEvent . OPENED ) ;
284
+
271
285
expect ( element . open ) . to . be . true ;
272
286
273
287
element . dispatchEvent ( new KeyboardEvent ( 'keyup' , { key : 'Escape' } ) ) ;
0 commit comments