@@ -976,37 +976,41 @@ describe('MdSelect', () => {
976
976
select . style . marginRight = '20px' ;
977
977
} ) ;
978
978
979
- it ( 'should align the trigger and the selected option on the x-axis in ltr' , ( ) => {
979
+ it ( 'should align the trigger and the selected option on the x-axis in ltr' , async ( ( ) => {
980
980
trigger . click ( ) ;
981
981
fixture . detectChanges ( ) ;
982
982
983
- const triggerLeft = trigger . getBoundingClientRect ( ) . left ;
984
- const firstOptionLeft =
985
- document . querySelector ( '.cdk-overlay-pane md-option' ) . getBoundingClientRect ( ) . left ;
986
-
987
- // Each option is 32px wider than the trigger, so it must be adjusted 16px
988
- // to ensure the text overlaps correctly.
989
- expect ( firstOptionLeft . toFixed ( 2 ) )
990
- . toEqual ( ( triggerLeft - 16 ) . toFixed ( 2 ) ,
991
- `Expected trigger to align with the selected option on the x-axis in LTR.` ) ;
992
- } ) ;
983
+ fixture . whenStable ( ) . then ( ( ) => {
984
+ const triggerLeft = trigger . getBoundingClientRect ( ) . left ;
985
+ const firstOptionLeft =
986
+ document . querySelector ( '.cdk-overlay-pane md-option' ) . getBoundingClientRect ( ) . left ;
987
+
988
+ // Each option is 32px wider than the trigger, so it must be adjusted 16px
989
+ // to ensure the text overlaps correctly.
990
+ expect ( firstOptionLeft . toFixed ( 2 ) )
991
+ . toEqual ( ( triggerLeft - 16 ) . toFixed ( 2 ) ,
992
+ `Expected trigger to align with the selected option on the x-axis in LTR.` ) ;
993
+ } ) ;
994
+ } ) ) ;
993
995
994
- it ( 'should align the trigger and the selected option on the x-axis in rtl' , ( ) => {
996
+ it ( 'should align the trigger and the selected option on the x-axis in rtl' , async ( ( ) => {
995
997
dir . value = 'rtl' ;
996
998
997
999
trigger . click ( ) ;
998
1000
fixture . detectChanges ( ) ;
999
1001
1000
- const triggerRight = trigger . getBoundingClientRect ( ) . right ;
1001
- const firstOptionRight =
1002
- document . querySelector ( '.cdk-overlay-pane md-option' ) . getBoundingClientRect ( ) . right ;
1003
-
1004
- // Each option is 32px wider than the trigger, so it must be adjusted 16px
1005
- // to ensure the text overlaps correctly.
1006
- expect ( firstOptionRight . toFixed ( 2 ) )
1007
- . toEqual ( ( triggerRight + 16 ) . toFixed ( 2 ) ,
1008
- `Expected trigger to align with the selected option on the x-axis in RTL.` ) ;
1009
- } ) ;
1002
+ fixture . whenStable ( ) . then ( ( ) => {
1003
+ const triggerRight = trigger . getBoundingClientRect ( ) . right ;
1004
+ const firstOptionRight =
1005
+ document . querySelector ( '.cdk-overlay-pane md-option' ) . getBoundingClientRect ( ) . right ;
1006
+
1007
+ // Each option is 32px wider than the trigger, so it must be adjusted 16px
1008
+ // to ensure the text overlaps correctly.
1009
+ expect ( firstOptionRight . toFixed ( 2 ) )
1010
+ . toEqual ( ( triggerRight + 16 ) . toFixed ( 2 ) ,
1011
+ `Expected trigger to align with the selected option on the x-axis in RTL.` ) ;
1012
+ } ) ;
1013
+ } ) ) ;
1010
1014
} ) ;
1011
1015
1012
1016
} ) ;
0 commit comments