@@ -182,24 +182,23 @@ describe('MdAutocomplete', () => {
182
182
} ) ;
183
183
} ) ) ;
184
184
185
- it ( 'should keep the label floating until the panel closes' , ( ) => {
185
+ it ( 'should keep the label floating until the panel closes' , async ( ( ) => {
186
186
fixture . componentInstance . trigger . openPanel ( ) ;
187
- fixture . detectChanges ( ) ;
188
-
189
- dispatchEvent ( 'blur' , input ) ;
190
- fixture . detectChanges ( ) ;
191
-
192
187
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 .' ) ;
194
189
195
- const backdrop =
196
- overlayContainerElement . querySelector ( '.cdk-overlay-backdrop' ) as HTMLElement ;
197
- backdrop . click ( ) ;
198
- fixture . detectChanges ( ) ;
190
+ fixture . whenStable ( ) . then ( ( ) => {
191
+ fixture . detectChanges ( ) ;
199
192
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
+ } ) ) ;
203
202
204
203
} ) ;
205
204
@@ -739,8 +738,8 @@ describe('MdAutocomplete', () => {
739
738
const panelTop = panel . getBoundingClientRect ( ) . top ;
740
739
741
740
// 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.` ) ;
744
743
expect ( fixture . componentInstance . trigger . autocomplete . positionY )
745
744
. toEqual ( 'below' , `Expected autocomplete positionY to default to below.` ) ;
746
745
} ) ;
@@ -758,8 +757,8 @@ describe('MdAutocomplete', () => {
758
757
const panelBottom = panel . getBoundingClientRect ( ) . bottom ;
759
758
760
759
// 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.` ) ;
763
762
expect ( fixture . componentInstance . trigger . autocomplete . positionY )
764
763
. toEqual ( 'above' , `Expected autocomplete positionY to be "above" if panel won't fit.` ) ;
765
764
} ) ;
@@ -782,8 +781,8 @@ describe('MdAutocomplete', () => {
782
781
const panelBottom = panel . getBoundingClientRect ( ) . bottom ;
783
782
784
783
// 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.` ) ;
787
786
expect ( fixture . componentInstance . trigger . autocomplete . positionY )
788
787
. toEqual ( 'above' , `Expected autocomplete positionY to be "above" if panel won't fit.` ) ;
789
788
} ) ;
0 commit comments