@@ -1055,27 +1055,26 @@ describe('MdAutocomplete', () => {
10551055 describe ( 'Fallback positions' , ( ) => {
10561056 let fixture : ComponentFixture < SimpleAutocomplete > ;
10571057 let input : HTMLInputElement ;
1058+ let inputReference : HTMLInputElement ;
10581059
10591060 beforeEach ( ( ) => {
10601061 fixture = TestBed . createComponent ( SimpleAutocomplete ) ;
10611062 fixture . detectChanges ( ) ;
10621063
10631064 input = fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement ;
1065+ inputReference = fixture . debugElement . query ( By . css ( '.mat-input-flex' ) ) . nativeElement ;
10641066 } ) ;
10651067
10661068 it ( 'should use below positioning by default' , ( ) => {
10671069 fixture . componentInstance . trigger . openPanel ( ) ;
10681070 fixture . detectChanges ( ) ;
10691071
1070- const inputBottom = input . getBoundingClientRect ( ) . bottom ;
1072+ const inputBottom = inputReference . getBoundingClientRect ( ) . bottom ;
10711073 const panel = overlayContainerElement . querySelector ( '.mat-autocomplete-panel' ) ! ;
10721074 const panelTop = panel . getBoundingClientRect ( ) . top ;
10731075
1074- // Panel is offset by 6px in styles so that the underline has room to display.
1075- expect ( Math . floor ( inputBottom + 6 ) )
1076+ expect ( Math . floor ( inputBottom ) )
10761077 . toEqual ( Math . floor ( panelTop ) , `Expected panel top to match input bottom by default.` ) ;
1077- expect ( fixture . componentInstance . trigger . autocomplete . positionY )
1078- . toEqual ( 'below' , `Expected autocomplete positionY to default to below.` ) ;
10791078 } ) ;
10801079
10811080 it ( 'should reposition the panel on scroll' , ( ) => {
@@ -1091,39 +1090,36 @@ describe('MdAutocomplete', () => {
10911090 scrolledSubject . next ( ) ;
10921091 fixture . detectChanges ( ) ;
10931092
1094- const inputBottom = input . getBoundingClientRect ( ) . bottom ;
1093+ const inputBottom = inputReference . getBoundingClientRect ( ) . bottom ;
10951094 const panel = overlayContainerElement . querySelector ( '.mat-autocomplete-panel' ) ! ;
10961095 const panelTop = panel . getBoundingClientRect ( ) . top ;
10971096
1098- expect ( Math . floor ( inputBottom + 6 ) ) . toEqual ( Math . floor ( panelTop ) ,
1097+ expect ( Math . floor ( inputBottom ) ) . toEqual ( Math . floor ( panelTop ) ,
10991098 'Expected panel top to match input bottom after scrolling.' ) ;
11001099
11011100 document . body . removeChild ( spacer ) ;
11021101 } ) ;
11031102
11041103 it ( 'should fall back to above position if panel cannot fit below' , ( ) => {
11051104 // Push the autocomplete trigger down so it won't have room to open "below"
1106- input . style . top = '600px' ;
1107- input . style . position = 'relative' ;
1105+ inputReference . style . top = '600px' ;
1106+ inputReference . style . position = 'relative' ;
11081107
11091108 fixture . componentInstance . trigger . openPanel ( ) ;
11101109 fixture . detectChanges ( ) ;
11111110
1112- const inputTop = input . getBoundingClientRect ( ) . top ;
1111+ const inputTop = inputReference . getBoundingClientRect ( ) . top ;
11131112 const panel = overlayContainerElement . querySelector ( '.mat-autocomplete-panel' ) ! ;
11141113 const panelBottom = panel . getBoundingClientRect ( ) . bottom ;
11151114
1116- // Panel is offset by 24px in styles so that the label has room to display.
1117- expect ( Math . floor ( inputTop - 24 ) )
1115+ expect ( Math . floor ( inputTop ) )
11181116 . toEqual ( Math . floor ( panelBottom ) , `Expected panel to fall back to above position.` ) ;
1119- expect ( fixture . componentInstance . trigger . autocomplete . positionY )
1120- . toEqual ( 'above' , `Expected autocomplete positionY to be "above" if panel won't fit.` ) ;
11211117 } ) ;
11221118
11231119 it ( 'should align panel properly when filtering in "above" position' , async ( ( ) => {
11241120 // Push the autocomplete trigger down so it won't have room to open "below"
1125- input . style . top = '600px' ;
1126- input . style . position = 'relative' ;
1121+ inputReference . style . top = '600px' ;
1122+ inputReference . style . position = 'relative' ;
11271123
11281124 fixture . componentInstance . trigger . openPanel ( ) ;
11291125 fixture . detectChanges ( ) ;
@@ -1132,15 +1128,12 @@ describe('MdAutocomplete', () => {
11321128 typeInElement ( 'f' , input ) ;
11331129 fixture . detectChanges ( ) ;
11341130
1135- const inputTop = input . getBoundingClientRect ( ) . top ;
1131+ const inputTop = inputReference . getBoundingClientRect ( ) . top ;
11361132 const panel = overlayContainerElement . querySelector ( '.mat-autocomplete-panel' ) ! ;
11371133 const panelBottom = panel . getBoundingClientRect ( ) . bottom ;
11381134
1139- // Panel is offset by 24px in styles so that the label has room to display.
1140- expect ( Math . floor ( inputTop - 24 ) )
1135+ expect ( Math . floor ( inputTop ) )
11411136 . toEqual ( Math . floor ( panelBottom ) , `Expected panel to stay aligned after filtering.` ) ;
1142- expect ( fixture . componentInstance . trigger . autocomplete . positionY )
1143- . toEqual ( 'above' , `Expected autocomplete positionY to be "above" if panel won't fit.` ) ;
11441137 } ) ;
11451138 } ) ) ;
11461139
0 commit comments