@@ -182,24 +182,23 @@ describe('MdAutocomplete', () => {
182182 } ) ;
183183 } ) ) ;
184184
185- it ( 'should keep the label floating until the panel closes' , ( ) => {
185+ it ( 'should keep the label floating until the panel closes' , async ( ( ) => {
186186 fixture . componentInstance . trigger . openPanel ( ) ;
187- fixture . detectChanges ( ) ;
188-
189- dispatchEvent ( 'blur' , input ) ;
190- fixture . detectChanges ( ) ;
191-
192187 expect ( fixture . componentInstance . inputContainer . floatPlaceholder )
193- . toEqual ( 'always' , 'Expected placeholder to keep floating on blur .' ) ;
188+ . toEqual ( 'always' , 'Expected placeholder to float as soon as panel opens .' ) ;
194189
195- const backdrop =
196- overlayContainerElement . querySelector ( '.cdk-overlay-backdrop' ) as HTMLElement ;
197- backdrop . click ( ) ;
198- fixture . detectChanges ( ) ;
190+ fixture . whenStable ( ) . then ( ( ) => {
191+ fixture . detectChanges ( ) ;
199192
200- expect ( fixture . componentInstance . inputContainer . floatPlaceholder )
201- . toEqual ( 'auto' , 'Expected placeholder to return to auto state after panel closes.' ) ;
202- } ) ;
193+ const options =
194+ overlayContainerElement . querySelectorAll ( 'md-option' ) as NodeListOf < HTMLElement > ;
195+ options [ 1 ] . click ( ) ;
196+ fixture . detectChanges ( ) ;
197+
198+ expect ( fixture . componentInstance . inputContainer . floatPlaceholder )
199+ . toEqual ( 'auto' , 'Expected placeholder to return to auto state after panel closes.' ) ;
200+ } ) ;
201+ } ) ) ;
203202
204203 } ) ;
205204
@@ -739,8 +738,8 @@ describe('MdAutocomplete', () => {
739738 const panelTop = panel . getBoundingClientRect ( ) . top ;
740739
741740 // Panel is offset by 6px in styles so that the underline has room to display.
742- expect ( ( inputBottom + 6 ) . toFixed ( 2 ) )
743- . toEqual ( panelTop . toFixed ( 2 ) , `Expected panel top to match input bottom by default.` ) ;
741+ expect ( ( inputBottom + 6 ) . toFixed ( 1 ) )
742+ . toEqual ( panelTop . toFixed ( 1 ) , `Expected panel top to match input bottom by default.` ) ;
744743 expect ( fixture . componentInstance . trigger . autocomplete . positionY )
745744 . toEqual ( 'below' , `Expected autocomplete positionY to default to below.` ) ;
746745 } ) ;
@@ -758,8 +757,8 @@ describe('MdAutocomplete', () => {
758757 const panelBottom = panel . getBoundingClientRect ( ) . bottom ;
759758
760759 // Panel is offset by 24px in styles so that the label has room to display.
761- expect ( ( inputTop - 24 ) . toFixed ( 2 ) )
762- . toEqual ( panelBottom . toFixed ( 2 ) , `Expected panel to fall back to above position.` ) ;
760+ expect ( ( inputTop - 24 ) . toFixed ( 1 ) )
761+ . toEqual ( panelBottom . toFixed ( 1 ) , `Expected panel to fall back to above position.` ) ;
763762 expect ( fixture . componentInstance . trigger . autocomplete . positionY )
764763 . toEqual ( 'above' , `Expected autocomplete positionY to be "above" if panel won't fit.` ) ;
765764 } ) ;
@@ -782,8 +781,8 @@ describe('MdAutocomplete', () => {
782781 const panelBottom = panel . getBoundingClientRect ( ) . bottom ;
783782
784783 // Panel is offset by 24px in styles so that the label has room to display.
785- expect ( ( inputTop - 24 ) . toFixed ( 2 ) )
786- . toEqual ( panelBottom . toFixed ( 2 ) , `Expected panel to stay aligned after filtering.` ) ;
784+ expect ( ( inputTop - 24 ) . toFixed ( 1 ) )
785+ . toEqual ( panelBottom . toFixed ( 1 ) , `Expected panel to stay aligned after filtering.` ) ;
787786 expect ( fixture . componentInstance . trigger . autocomplete . positionY )
788787 . toEqual ( 'above' , `Expected autocomplete positionY to be "above" if panel won't fit.` ) ;
789788 } ) ;
0 commit comments