@@ -50,7 +50,8 @@ describe('MdInputContainer', function () {
5050 MdInputContainerMissingMdInputTestController ,
5151 MdInputContainerMultipleHintTestController ,
5252 MdInputContainerMultipleHintMixedTestController ,
53- MdInputContainerWithDynamicPlaceholder
53+ MdInputContainerWithDynamicPlaceholder ,
54+ MdInputContainerWithPrefixAndSuffix
5455 ] ,
5556 } ) ;
5657
@@ -551,6 +552,29 @@ describe('MdInputContainer', function () {
551552 expect ( labelEl . classList ) . not . toContain ( 'mat-float' ) ;
552553 } ) ;
553554
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+ } ) ;
554578} ) ;
555579
556580@Component ( {
@@ -775,3 +799,14 @@ class MdTextareaWithBindings {
775799 template : `<md-input-container><input></md-input-container>`
776800} )
777801class 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