@@ -43,6 +43,7 @@ describe('MdInputContainer', function () {
43
43
MdInputContainerWithDisabled ,
44
44
MdInputContainerWithValueBinding ,
45
45
MdInputContainerWithFormControl ,
46
+ MdInputContainerWithStaticPlaceholder ,
46
47
MdInputContainerMissingMdInputTestController
47
48
] ,
48
49
} ) ;
@@ -130,6 +131,26 @@ describe('MdInputContainer', function () {
130
131
expect ( el . classList . contains ( 'md-empty' ) ) . toBe ( false , 'should not be empty' ) ;
131
132
} ) ) ;
132
133
134
+ it ( 'should update the placeholder when input entered' , async ( ( ) => {
135
+ let fixture = TestBed . createComponent ( MdInputContainerWithStaticPlaceholder ) ;
136
+ fixture . detectChanges ( ) ;
137
+
138
+ let inputEl = fixture . debugElement . query ( By . css ( 'input' ) ) ;
139
+ let labelEl = fixture . debugElement . query ( By . css ( 'label' ) ) . nativeElement ;
140
+
141
+ expect ( labelEl . classList ) . toContain ( 'md-empty' ) ;
142
+ expect ( labelEl . classList ) . not . toContain ( 'md-float' ) ;
143
+
144
+ // Update the value of the input.
145
+ inputEl . nativeElement . value = 'Text' ;
146
+
147
+ // Fake behavior of the `(input)` event which should trigger a change detection.
148
+ fixture . detectChanges ( ) ;
149
+
150
+ expect ( labelEl . classList ) . not . toContain ( 'md-empty' ) ;
151
+ expect ( labelEl . classList ) . not . toContain ( 'md-float' ) ;
152
+ } ) ) ;
153
+
133
154
it ( 'should not be empty when the value set before view init' , async ( ( ) => {
134
155
let fixture = TestBed . createComponent ( MdInputContainerWithValueBinding ) ;
135
156
fixture . detectChanges ( ) ;
@@ -476,6 +497,15 @@ class MdInputContainerWithValueBinding {
476
497
value : string = 'Initial' ;
477
498
}
478
499
500
+ @Component ( {
501
+ template : `
502
+ <md-input-container [floatingPlaceholder]="false">
503
+ <input md-input placeholder="Label">
504
+ </md-input-container>
505
+ `
506
+ } )
507
+ class MdInputContainerWithStaticPlaceholder { }
508
+
479
509
@Component ( {
480
510
template : `
481
511
<md-input-container>
0 commit comments