@@ -45,6 +45,7 @@ describe('MdInputContainer', function () {
45
45
MdInputContainerWithType ,
46
46
MdInputContainerWithValueBinding ,
47
47
MdInputContainerWithFormControl ,
48
+ MdInputContainerWithStaticPlaceholder ,
48
49
MdInputContainerMissingMdInputTestController
49
50
] ,
50
51
} ) ;
@@ -132,6 +133,26 @@ describe('MdInputContainer', function () {
132
133
expect ( el . classList . contains ( 'md-empty' ) ) . toBe ( false , 'should not be empty' ) ;
133
134
} ) ) ;
134
135
136
+ it ( 'should update the placeholder when input entered' , async ( ( ) => {
137
+ let fixture = TestBed . createComponent ( MdInputContainerWithStaticPlaceholder ) ;
138
+ fixture . detectChanges ( ) ;
139
+
140
+ let inputEl = fixture . debugElement . query ( By . css ( 'input' ) ) ;
141
+ let labelEl = fixture . debugElement . query ( By . css ( 'label' ) ) . nativeElement ;
142
+
143
+ expect ( labelEl . classList ) . toContain ( 'md-empty' ) ;
144
+ expect ( labelEl . classList ) . not . toContain ( 'md-float' ) ;
145
+
146
+ // Update the value of the input.
147
+ inputEl . nativeElement . value = 'Text' ;
148
+
149
+ // Fake behavior of the `(input)` event which should trigger a change detection.
150
+ fixture . detectChanges ( ) ;
151
+
152
+ expect ( labelEl . classList ) . not . toContain ( 'md-empty' ) ;
153
+ expect ( labelEl . classList ) . not . toContain ( 'md-float' ) ;
154
+ } ) ) ;
155
+
135
156
it ( 'should not be empty when the value set before view init' , async ( ( ) => {
136
157
let fixture = TestBed . createComponent ( MdInputContainerWithValueBinding ) ;
137
158
fixture . detectChanges ( ) ;
@@ -529,6 +550,15 @@ class MdInputContainerWithValueBinding {
529
550
value : string = 'Initial' ;
530
551
}
531
552
553
+ @Component ( {
554
+ template : `
555
+ <md-input-container [floatingPlaceholder]="false">
556
+ <input md-input placeholder="Label">
557
+ </md-input-container>
558
+ `
559
+ } )
560
+ class MdInputContainerWithStaticPlaceholder { }
561
+
532
562
@Component ( {
533
563
template : `
534
564
<md-input-container>
0 commit comments