@@ -988,37 +988,50 @@ describe('MdSelect', () => {
988
988
select . style . marginRight = '30px' ;
989
989
} ) ;
990
990
991
- it ( 'should align the trigger and the selected option on the x-axis in ltr' , ( ) => {
992
- trigger . click ( ) ;
993
- fixture . detectChanges ( ) ;
991
+ it ( 'should align the trigger and the selected option on the x-axis in ltr' , async ( ( ) => {
992
+ fixture . whenStable ( ) . then ( ( ) => {
993
+ fixture . detectChanges ( ) ;
994
994
995
- const triggerLeft = trigger . getBoundingClientRect ( ) . left ;
996
- const firstOptionLeft =
997
- document . querySelector ( '.cdk-overlay-pane md-option' ) . getBoundingClientRect ( ) . left ;
995
+ trigger . click ( ) ;
996
+ fixture . detectChanges ( ) ;
998
997
999
- // Each option is 32px wider than the trigger, so it must be adjusted 16px
1000
- // to ensure the text overlaps correctly.
1001
- expect ( firstOptionLeft . toFixed ( 2 ) )
1002
- . toEqual ( ( triggerLeft - 16 ) . toFixed ( 2 ) ,
998
+ fixture . whenStable ( ) . then ( ( ) => {
999
+ fixture . detectChanges ( ) ;
1000
+
1001
+ const triggerLeft = trigger . getBoundingClientRect ( ) . left ;
1002
+ const firstOptionLeft = document . querySelector ( '.cdk-overlay-pane md-option' )
1003
+ . getBoundingClientRect ( ) . left ;
1004
+
1005
+ // Each option is 32px wider than the trigger, so it must be adjusted 16px
1006
+ // to ensure the text overlaps correctly.
1007
+ expect ( firstOptionLeft . toFixed ( 2 ) ) . toEqual ( ( triggerLeft - 16 ) . toFixed ( 2 ) ,
1003
1008
`Expected trigger to align with the selected option on the x-axis in LTR.` ) ;
1004
- } ) ;
1009
+ } ) ;
1010
+ } ) ;
1011
+ } ) ) ;
1005
1012
1006
- it ( 'should align the trigger and the selected option on the x-axis in rtl' , ( ) => {
1013
+ it ( 'should align the trigger and the selected option on the x-axis in rtl' , async ( ( ) => {
1007
1014
dir . value = 'rtl' ;
1015
+ fixture . whenStable ( ) . then ( ( ) => {
1016
+ fixture . detectChanges ( ) ;
1008
1017
1009
- trigger . click ( ) ;
1010
- fixture . detectChanges ( ) ;
1011
-
1012
- const triggerRight = trigger . getBoundingClientRect ( ) . right ;
1013
- const firstOptionRight =
1014
- document . querySelector ( '.cdk-overlay-pane md-option' ) . getBoundingClientRect ( ) . right ;
1018
+ trigger . click ( ) ;
1019
+ fixture . detectChanges ( ) ;
1015
1020
1016
- // Each option is 32px wider than the trigger, so it must be adjusted 16px
1017
- // to ensure the text overlaps correctly.
1018
- expect ( firstOptionRight . toFixed ( 2 ) )
1019
- . toEqual ( ( triggerRight + 16 ) . toFixed ( 2 ) ,
1020
- `Expected trigger to align with the selected option on the x-axis in RTL.` ) ;
1021
- } ) ;
1021
+ fixture . whenStable ( ) . then ( ( ) => {
1022
+ fixture . detectChanges ( ) ;
1023
+ const triggerRight = trigger . getBoundingClientRect ( ) . right ;
1024
+ const firstOptionRight =
1025
+ document . querySelector ( '.cdk-overlay-pane md-option' ) . getBoundingClientRect ( ) . right ;
1026
+
1027
+ // Each option is 32px wider than the trigger, so it must be adjusted 16px
1028
+ // to ensure the text overlaps correctly.
1029
+ expect ( firstOptionRight . toFixed ( 2 ) )
1030
+ . toEqual ( ( triggerRight + 16 ) . toFixed ( 2 ) ,
1031
+ `Expected trigger to align with the selected option on the x-axis in RTL.` ) ;
1032
+ } ) ;
1033
+ } ) ;
1034
+ } ) ) ;
1022
1035
} ) ;
1023
1036
1024
1037
describe ( 'x-axis positioning in multi select mode' , ( ) => {
@@ -1450,13 +1463,13 @@ describe('MdSelect', () => {
1450
1463
let testInstance : MultiSelect ;
1451
1464
let trigger : HTMLElement ;
1452
1465
1453
- beforeEach ( ( ) => {
1466
+ beforeEach ( async ( ( ) => {
1454
1467
fixture = TestBed . createComponent ( MultiSelect ) ;
1455
1468
testInstance = fixture . componentInstance ;
1456
1469
fixture . detectChanges ( ) ;
1457
1470
1458
1471
trigger = fixture . debugElement . query ( By . css ( '.mat-select-trigger' ) ) . nativeElement ;
1459
- } ) ;
1472
+ } ) ) ;
1460
1473
1461
1474
it ( 'should be able to select multiple values' , ( ) => {
1462
1475
trigger . click ( ) ;
@@ -1616,17 +1629,17 @@ describe('MdSelect', () => {
1616
1629
expect ( trigger . textContent ) . toContain ( 'Tacos, Pizza, Steak' ) ;
1617
1630
} ) ;
1618
1631
1619
- it ( 'should throw an exception when trying to set a non-array value' , ( ) => {
1632
+ it ( 'should throw an exception when trying to set a non-array value' , async ( ( ) => {
1620
1633
expect ( ( ) => {
1621
1634
testInstance . control . setValue ( 'not-an-array' ) ;
1622
1635
} ) . toThrowError ( wrappedErrorMessage ( new MdSelectNonArrayValueError ( ) ) ) ;
1623
- } ) ;
1636
+ } ) ) ;
1624
1637
1625
- it ( 'should throw an exception when trying to change multiple mode after init' , ( ) => {
1638
+ it ( 'should throw an exception when trying to change multiple mode after init' , async ( ( ) => {
1626
1639
expect ( ( ) => {
1627
1640
testInstance . select . multiple = false ;
1628
1641
} ) . toThrowError ( wrappedErrorMessage ( new MdSelectDynamicMultipleError ( ) ) ) ;
1629
- } ) ;
1642
+ } ) ) ;
1630
1643
1631
1644
it ( 'should pass the `multiple` value to all of the option instances' , async ( ( ) => {
1632
1645
trigger . click ( ) ;
0 commit comments