@@ -112,20 +112,18 @@ describe('items', () => {
112112 expect ( subItemRect . right ) . to . be . below ( rootItemRect . left ) ;
113113 } ) ;
114114
115- ( isIOS ? it . skip : it ) ( 'should open the subMenu on the top if root menu is bottom-aligned' , ( done ) => {
115+ ( isIOS ? it . skip : it ) ( 'should open the subMenu on the top if root menu is bottom-aligned' , async ( ) => {
116116 subMenu . close ( ) ;
117117 const rootItemRect = menuComponents ( ) [ 0 ] . getBoundingClientRect ( ) ;
118118 rootMenu . $ . overlay . style . removeProperty ( 'top' ) ;
119119 rootMenu . $ . overlay . style . bottom = rootItemRect . height * 2 + 'px' ;
120120 rootMenu . $ . overlay . setAttribute ( 'bottom-aligned' , '' ) ;
121121 open ( menuComponents ( ) [ 0 ] ) ;
122122
123- afterNextRender ( subMenu , ( ) => {
124- const rootMenuRect = rootMenu . $ . overlay . getBoundingClientRect ( ) ;
125- const subMenuRect = subMenu . $ . overlay . getBoundingClientRect ( ) ;
126- expect ( subMenuRect . bottom ) . to . be . below ( rootMenuRect . bottom ) ;
127- done ( ) ;
128- } ) ;
123+ await nextRender ( subMenu ) ;
124+ const rootMenuRect = rootMenu . $ . overlay . getBoundingClientRect ( ) ;
125+ const subMenuRect = subMenu . $ . overlay . getBoundingClientRect ( ) ;
126+ expect ( subMenuRect . bottom ) . to . be . below ( rootMenuRect . bottom ) ;
129127 } ) ;
130128
131129 ( isIOS ? it . skip : it ) ( 'should open the subMenu on the left if root menu is end-aligned' , async ( ) => {
@@ -305,15 +303,13 @@ describe('items', () => {
305303 expect ( subMenu . opened ) . to . be . true ;
306304 } ) ;
307305
308- it ( 'should open item on left arrow if RTL' , ( done ) => {
306+ it ( 'should open item on left arrow if RTL' , async ( ) => {
309307 document . documentElement . setAttribute ( 'dir' , 'rtl' ) ;
310- requestAnimationFrame ( ( ) => {
311- subMenu . close ( ) ;
312- fire ( menuComponents ( ) [ 0 ] , 'keydown' , { } , { keyCode : 37 , key : 'ArrowLeft' } ) ;
313- expect ( subMenu . opened ) . to . be . true ;
314- document . documentElement . setAttribute ( 'dir' , 'ltr' ) ;
315- done ( ) ;
316- } ) ;
308+ await nextFrame ( ) ;
309+ subMenu . close ( ) ;
310+ fire ( menuComponents ( ) [ 0 ] , 'keydown' , { } , { keyCode : 37 , key : 'ArrowLeft' } ) ;
311+ expect ( subMenu . opened ) . to . be . true ;
312+ document . documentElement . setAttribute ( 'dir' , 'ltr' ) ;
317313 } ) ;
318314
319315 it ( 'should open item on enter' , ( ) => {
@@ -454,7 +450,7 @@ describe('items', () => {
454450 await nextFrame ( ) ;
455451 } ) ;
456452
457- it ( 'Should properly move overlays on scrolling distance within y axis' , ( done ) => {
453+ it ( 'Should properly move overlays on scrolling distance within y axis' , async ( ) => {
458454 const scrollDistance = 150 ;
459455
460456 // Default indentation is 16
@@ -463,15 +459,13 @@ describe('items', () => {
463459 const subBRCTop2 = subOverlay2 . getBoundingClientRect ( ) . top ;
464460
465461 scrollElm . scrollTop = scrollDistance ;
466- afterNextRender ( rootMenu , ( ) => {
467- expect ( rootOverlay . getBoundingClientRect ( ) . top ) . to . be . closeTo ( rootBRCTop - scrollDistance , 1 ) ;
468- expect ( subOverlay1 . getBoundingClientRect ( ) . top ) . to . be . closeTo ( subBRCTop1 - scrollDistance , 1 ) ;
469- expect ( subOverlay2 . getBoundingClientRect ( ) . top ) . to . be . closeTo ( subBRCTop2 - scrollDistance , 1 ) ;
470- done ( ) ;
471- } ) ;
462+ await nextRender ( rootMenu ) ;
463+ expect ( rootOverlay . getBoundingClientRect ( ) . top ) . to . be . closeTo ( rootBRCTop - scrollDistance , 1 ) ;
464+ expect ( subOverlay1 . getBoundingClientRect ( ) . top ) . to . be . closeTo ( subBRCTop1 - scrollDistance , 1 ) ;
465+ expect ( subOverlay2 . getBoundingClientRect ( ) . top ) . to . be . closeTo ( subBRCTop2 - scrollDistance , 1 ) ;
472466 } ) ;
473467
474- it ( 'Should properly move overlays on scrolling distance within x axis' , ( done ) => {
468+ it ( 'Should properly move overlays on scrolling distance within x axis' , async ( ) => {
475469 const scrollDistance = 150 ;
476470
477471 // Default indentation is 16
@@ -480,12 +474,10 @@ describe('items', () => {
480474 const subBRCLeft2 = subOverlay2 . getBoundingClientRect ( ) . left ;
481475
482476 scrollElm . scrollLeft = scrollDistance ;
483- afterNextRender ( rootMenu , ( ) => {
484- expect ( rootOverlay . getBoundingClientRect ( ) . left ) . to . be . closeTo ( rootBRCLeft - scrollDistance , 1 ) ;
485- expect ( subOverlay1 . getBoundingClientRect ( ) . left ) . to . be . closeTo ( subBRCLeft1 - scrollDistance , 1 ) ;
486- expect ( subOverlay2 . getBoundingClientRect ( ) . left ) . to . be . closeTo ( subBRCLeft2 - scrollDistance , 1 ) ;
487- done ( ) ;
488- } ) ;
477+ await nextRender ( rootMenu ) ;
478+ expect ( rootOverlay . getBoundingClientRect ( ) . left ) . to . be . closeTo ( rootBRCLeft - scrollDistance , 1 ) ;
479+ expect ( subOverlay1 . getBoundingClientRect ( ) . left ) . to . be . closeTo ( subBRCLeft1 - scrollDistance , 1 ) ;
480+ expect ( subOverlay2 . getBoundingClientRect ( ) . left ) . to . be . closeTo ( subBRCLeft2 - scrollDistance , 1 ) ;
489481 } ) ;
490482 } ) ;
491483 } ) ;
0 commit comments