@@ -35,6 +35,62 @@ describe('MdInput', function () {
3535 } ) ;
3636 } ) ) ;
3737
38+ it ( 'should not be treated as empty if type is date' , ( ) => {
39+ return builder . createAsync ( MdInputDateTestController )
40+ . then ( fixture => {
41+ fakeAsync ( ( ) => {
42+ fixture . componentInstance . placeholder = 'Placeholder' ;
43+ fixture . detectChanges ( ) ;
44+
45+ let el = fixture . debugElement . query ( By . css ( 'label' ) ) . nativeElement ;
46+ expect ( el ) . not . toBeNull ( ) ;
47+ expect ( el . className . includes ( 'md-empty' ) ) . toBe ( false ) ;
48+ } ) ( ) ;
49+ } ) ;
50+ } ) ;
51+
52+ it ( 'should treat text input type as empty at init' , ( ) => {
53+ return builder . createAsync ( MdInputTextTestController )
54+ . then ( fixture => {
55+ fakeAsync ( ( ) => {
56+ fixture . componentInstance . placeholder = 'Placeholder' ;
57+ fixture . detectChanges ( ) ;
58+
59+ let el = fixture . debugElement . query ( By . css ( 'label' ) ) . nativeElement ;
60+ expect ( el ) . not . toBeNull ( ) ;
61+ expect ( el . className . includes ( 'md-empty' ) ) . toBe ( true ) ;
62+ } ) ( ) ;
63+ } ) ;
64+ } ) ;
65+
66+ it ( 'should treat password input type as empty at init' , ( ) => {
67+ return builder . createAsync ( MdInputPasswordTestController )
68+ . then ( fixture => {
69+ fakeAsync ( ( ) => {
70+ fixture . componentInstance . placeholder = 'Placeholder' ;
71+ fixture . detectChanges ( ) ;
72+
73+ let el = fixture . debugElement . query ( By . css ( 'label' ) ) . nativeElement ;
74+ expect ( el ) . not . toBeNull ( ) ;
75+ expect ( el . className . includes ( 'md-empty' ) ) . toBe ( true ) ;
76+ } ) ( ) ;
77+ } ) ;
78+ } ) ;
79+
80+ it ( 'should treat number input type as empty at init' , ( ) => {
81+ return builder . createAsync ( MdInputNumberTestController )
82+ . then ( fixture => {
83+ fakeAsync ( ( ) => {
84+ fixture . componentInstance . placeholder = 'Placeholder' ;
85+ fixture . detectChanges ( ) ;
86+
87+ let el = fixture . debugElement . query ( By . css ( 'label' ) ) . nativeElement ;
88+ expect ( el ) . not . toBeNull ( ) ;
89+ expect ( el . className . includes ( 'md-empty' ) ) . toBe ( true ) ;
90+ } ) ( ) ;
91+ } ) ;
92+ } ) ;
93+
3894 it ( 'support ngModel' , async ( ( ) => {
3995 builder . createAsync ( MdInputBaseTestController )
4096 . then ( fixture => {
@@ -777,3 +833,39 @@ class MdInputOptionalAttributeController {}
777833 directives : [ MdInput ]
778834} )
779835class MdInputWithNameTestController { }
836+
837+ @Component ( {
838+ selector : 'test-input-controller' ,
839+ template : `
840+ <md-input type="date" [placeholder]="placeholder"></md-input>
841+ ` ,
842+ directives : [ MdInput ]
843+ } )
844+ class MdInputDateTestController { }
845+
846+ @Component ( {
847+ selector : 'test-input-controller' ,
848+ template : `
849+ <md-input type="text" [placeholder]="placeholder"></md-input>
850+ ` ,
851+ directives : [ MdInput ]
852+ } )
853+ class MdInputTextTestController { }
854+
855+ @Component ( {
856+ selector : 'test-input-controller' ,
857+ template : `
858+ <md-input type="password" [placeholder]="placeholder"></md-input>
859+ ` ,
860+ directives : [ MdInput ]
861+ } )
862+ class MdInputPasswordTestController { }
863+
864+ @Component ( {
865+ selector : 'test-input-controller' ,
866+ template : `
867+ <md-input type="number" [placeholder]="placeholder"></md-input>
868+ ` ,
869+ directives : [ MdInput ]
870+ } )
871+ class MdInputNumberTestController { }
0 commit comments