@@ -988,37 +988,50 @@ describe('MdSelect', () => {
988988 select . style . marginRight = '30px' ;
989989 } ) ;
990990
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 ( ) ;
994994
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 ( ) ;
998997
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 ) ,
10031008 `Expected trigger to align with the selected option on the x-axis in LTR.` ) ;
1004- } ) ;
1009+ } ) ;
1010+ } ) ;
1011+ } ) ) ;
10051012
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 ( ( ) => {
10071014 dir . value = 'rtl' ;
1015+ fixture . whenStable ( ) . then ( ( ) => {
1016+ fixture . detectChanges ( ) ;
10081017
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 ( ) ;
10151020
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+ } ) ) ;
10221035 } ) ;
10231036
10241037 describe ( 'x-axis positioning in multi select mode' , ( ) => {
@@ -1450,13 +1463,13 @@ describe('MdSelect', () => {
14501463 let testInstance : MultiSelect ;
14511464 let trigger : HTMLElement ;
14521465
1453- beforeEach ( ( ) => {
1466+ beforeEach ( async ( ( ) => {
14541467 fixture = TestBed . createComponent ( MultiSelect ) ;
14551468 testInstance = fixture . componentInstance ;
14561469 fixture . detectChanges ( ) ;
14571470
14581471 trigger = fixture . debugElement . query ( By . css ( '.mat-select-trigger' ) ) . nativeElement ;
1459- } ) ;
1472+ } ) ) ;
14601473
14611474 it ( 'should be able to select multiple values' , ( ) => {
14621475 trigger . click ( ) ;
@@ -1616,17 +1629,17 @@ describe('MdSelect', () => {
16161629 expect ( trigger . textContent ) . toContain ( 'Tacos, Pizza, Steak' ) ;
16171630 } ) ;
16181631
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 ( ( ) => {
16201633 expect ( ( ) => {
16211634 testInstance . control . setValue ( 'not-an-array' ) ;
16221635 } ) . toThrowError ( wrappedErrorMessage ( new MdSelectNonArrayValueError ( ) ) ) ;
1623- } ) ;
1636+ } ) ) ;
16241637
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 ( ( ) => {
16261639 expect ( ( ) => {
16271640 testInstance . select . multiple = false ;
16281641 } ) . toThrowError ( wrappedErrorMessage ( new MdSelectDynamicMultipleError ( ) ) ) ;
1629- } ) ;
1642+ } ) ) ;
16301643
16311644 it ( 'should pass the `multiple` value to all of the option instances' , async ( ( ) => {
16321645 trigger . click ( ) ;
0 commit comments