@@ -62,6 +62,7 @@ describe('MdInputContainer without forms', function () {
62
62
MdTextareaWithBindings ,
63
63
MdInputContainerWithNgIf ,
64
64
MdInputContainerOnPush ,
65
+ MdInputContainerWithReadonlyInput ,
65
66
] ,
66
67
} ) ;
67
68
@@ -604,6 +605,39 @@ describe('MdInputContainer without forms', function () {
604
605
605
606
expect ( placeholder . classList ) . not . toContain ( 'mat-empty' , 'Input no longer empty' ) ;
606
607
} ) ;
608
+
609
+ it ( 'should set the focused class when the input is focused' , ( ) => {
610
+ let fixture = TestBed . createComponent ( MdInputContainerTextTestController ) ;
611
+ fixture . detectChanges ( ) ;
612
+
613
+ let input = fixture . debugElement . query ( By . directive ( MdInputDirective ) )
614
+ . injector . get < MdInputDirective > ( MdInputDirective ) ;
615
+ let container = fixture . debugElement . query ( By . css ( 'md-input-container' ) ) . nativeElement ;
616
+
617
+ // Call the focus handler directly to avoid flakyness where
618
+ // browsers don't focus elements if the window is minimized.
619
+ input . _onFocus ( ) ;
620
+ fixture . detectChanges ( ) ;
621
+
622
+ expect ( container . classList ) . toContain ( 'mat-focused' ) ;
623
+ } ) ;
624
+
625
+ it ( 'should not highlight when focusing a readonly input' , ( ) => {
626
+ let fixture = TestBed . createComponent ( MdInputContainerWithReadonlyInput ) ;
627
+ fixture . detectChanges ( ) ;
628
+
629
+ let input = fixture . debugElement . query ( By . directive ( MdInputDirective ) )
630
+ . injector . get < MdInputDirective > ( MdInputDirective ) ;
631
+ let container = fixture . debugElement . query ( By . css ( 'md-input-container' ) ) . nativeElement ;
632
+
633
+ // Call the focus handler directly to avoid flakyness where
634
+ // browsers don't focus elements if the window is minimized.
635
+ input . _onFocus ( ) ;
636
+ fixture . detectChanges ( ) ;
637
+
638
+ expect ( input . focused ) . toBe ( false ) ;
639
+ expect ( container . classList ) . not . toContain ( 'mat-focused' ) ;
640
+ } ) ;
607
641
} ) ;
608
642
609
643
describe ( 'MdInputContainer with forms' , ( ) => {
@@ -1230,3 +1264,12 @@ class MdInputContainerWithNgIf {
1230
1264
class MdInputContainerOnPush {
1231
1265
formControl = new FormControl ( '' ) ;
1232
1266
}
1267
+
1268
+ @Component ( {
1269
+ template : `
1270
+ <md-input-container>
1271
+ <input mdInput readonly value="Only for reading">
1272
+ </md-input-container>
1273
+ `
1274
+ } )
1275
+ class MdInputContainerWithReadonlyInput { }
0 commit comments