@@ -50,7 +50,8 @@ describe('MdInputContainer', function () {
50
50
MdInputContainerMissingMdInputTestController ,
51
51
MdInputContainerMultipleHintTestController ,
52
52
MdInputContainerMultipleHintMixedTestController ,
53
- MdInputContainerWithDynamicPlaceholder
53
+ MdInputContainerWithDynamicPlaceholder ,
54
+ MdInputContainerWithPrefixAndSuffix
54
55
] ,
55
56
} ) ;
56
57
@@ -551,6 +552,29 @@ describe('MdInputContainer', function () {
551
552
expect ( labelEl . classList ) . not . toContain ( 'mat-float' ) ;
552
553
} ) ;
553
554
555
+ it ( 'should not have prefix and suffix elements when none are specified' , ( ) => {
556
+ let fixture = TestBed . createComponent ( MdInputContainerWithId ) ;
557
+ fixture . detectChanges ( ) ;
558
+
559
+ let prefixEl = fixture . debugElement . query ( By . css ( '.mat-input-prefix' ) ) ;
560
+ let suffixEl = fixture . debugElement . query ( By . css ( '.mat-input-suffix' ) ) ;
561
+
562
+ expect ( prefixEl ) . toBeNull ( ) ;
563
+ expect ( suffixEl ) . toBeNull ( ) ;
564
+ } ) ;
565
+
566
+ it ( 'should add prefix and suffix elements when specified' , ( ) => {
567
+ let fixture = TestBed . createComponent ( MdInputContainerWithPrefixAndSuffix ) ;
568
+ fixture . detectChanges ( ) ;
569
+
570
+ let prefixEl = fixture . debugElement . query ( By . css ( '.mat-input-prefix' ) ) ;
571
+ let suffixEl = fixture . debugElement . query ( By . css ( '.mat-input-suffix' ) ) ;
572
+
573
+ expect ( prefixEl ) . not . toBeNull ( ) ;
574
+ expect ( suffixEl ) . not . toBeNull ( ) ;
575
+ expect ( prefixEl . nativeElement . innerText . trim ( ) ) . toEqual ( 'Prefix' ) ;
576
+ expect ( suffixEl . nativeElement . innerText . trim ( ) ) . toEqual ( 'Suffix' ) ;
577
+ } ) ;
554
578
} ) ;
555
579
556
580
@Component ( {
@@ -775,3 +799,14 @@ class MdTextareaWithBindings {
775
799
template : `<md-input-container><input></md-input-container>`
776
800
} )
777
801
class MdInputContainerMissingMdInputTestController { }
802
+
803
+ @Component ( {
804
+ template : `
805
+ <md-input-container>
806
+ <div mdPrefix>Prefix</div>
807
+ <input mdInput>
808
+ <div mdSuffix>Suffix</div>
809
+ </md-input-container>
810
+ `
811
+ } )
812
+ class MdInputContainerWithPrefixAndSuffix { }
0 commit comments