@@ -16,7 +16,13 @@ describe('MdSelect', () => {
1616 beforeEach ( async ( ( ) => {
1717 TestBed . configureTestingModule ( {
1818 imports : [ MdSelectModule . forRoot ( ) , ReactiveFormsModule , FormsModule ] ,
19- declarations : [ BasicSelect , NgModelSelect , ManySelects , NgIfSelect ] ,
19+ declarations : [
20+ BasicSelect ,
21+ NgModelSelect ,
22+ ManySelects ,
23+ NgIfSelect ,
24+ FloatingPlaceholderSelect
25+ ] ,
2026 providers : [
2127 { provide : OverlayContainer , useFactory : ( ) => {
2228 overlayContainerElement = document . createElement ( 'div' ) as HTMLElement ;
@@ -1139,6 +1145,20 @@ describe('MdSelect', () => {
11391145 } ) ;
11401146 } ) ) ;
11411147
1148+ it ( 'should be able to disable the floating placeholder' , ( ) => {
1149+ let fixture = TestBed . createComponent ( FloatingPlaceholderSelect ) ;
1150+ let placeholder = fixture . debugElement . query ( By . css ( '.md-select-placeholder' ) ) . nativeElement ;
1151+
1152+ fixture . detectChanges ( ) ;
1153+
1154+ expect ( placeholder . style . visibility ) . toBe ( 'visible' ) ;
1155+
1156+ fixture . componentInstance . control . setValue ( 'pizza-1' ) ;
1157+ fixture . detectChanges ( ) ;
1158+
1159+ expect ( placeholder . style . visibility ) . toBe ( 'hidden' ) ;
1160+ } ) ;
1161+
11421162 } ) ;
11431163
11441164} ) ;
@@ -1235,6 +1255,29 @@ class NgIfSelect {
12351255 @ViewChild ( MdSelect ) select : MdSelect ;
12361256}
12371257
1258+ @Component ( {
1259+ selector : 'floating-placeholder-select' ,
1260+ template : `
1261+ <md-select placeholder="Food I want to eat right now" [formControl]="control"
1262+ [floatingPlaceholder]="floatingPlaceholder">
1263+ <md-option *ngFor="let food of foods" [value]="food.value">
1264+ {{ food.viewValue }}
1265+ </md-option>
1266+ </md-select>
1267+ ` ,
1268+
1269+ } )
1270+ class FloatingPlaceholderSelect {
1271+ floatingPlaceholder : boolean = false ;
1272+ foods : any [ ] = [
1273+ { value : 'steak-0' , viewValue : 'Steak' } ,
1274+ { value : 'pizza-1' , viewValue : 'Pizza' } ,
1275+ { value : 'tacos-2' , viewValue : 'Tacos' }
1276+ ] ;
1277+ control = new FormControl ( ) ;
1278+
1279+ @ViewChild ( MdSelect ) select : MdSelect ;
1280+ }
12381281
12391282
12401283/**
0 commit comments