@@ -49,7 +49,8 @@ describe('MdInputContainer', function () {
4949 MdInputContainerMissingMdInputTestController ,
5050 MdInputContainerMultipleHintTestController ,
5151 MdInputContainerMultipleHintMixedTestController ,
52- MdInputContainerWithDynamicPlaceholder
52+ MdInputContainerWithDynamicPlaceholder ,
53+ MdInputContainerWithPrefixAndSuffix
5354 ] ,
5455 } ) ;
5556
@@ -550,6 +551,29 @@ describe('MdInputContainer', function () {
550551 expect ( labelEl . classList ) . not . toContain ( 'mat-float' ) ;
551552 } ) ;
552553
554+ it ( 'should not have prefix and suffix elements when none are specified' , ( ) => {
555+ let fixture = TestBed . createComponent ( MdInputContainerWithId ) ;
556+ fixture . detectChanges ( ) ;
557+
558+ let prefixEl = fixture . debugElement . query ( By . css ( '.mat-input-prefix' ) ) ;
559+ let suffixEl = fixture . debugElement . query ( By . css ( '.mat-input-suffix' ) ) ;
560+
561+ expect ( prefixEl ) . toBeNull ( ) ;
562+ expect ( suffixEl ) . toBeNull ( ) ;
563+ } ) ;
564+
565+ it ( 'should add prefix and suffix elements when specified' , ( ) => {
566+ let fixture = TestBed . createComponent ( MdInputContainerWithPrefixAndSuffix ) ;
567+ fixture . detectChanges ( ) ;
568+
569+ let prefixEl = fixture . debugElement . query ( By . css ( '.mat-input-prefix' ) ) ;
570+ let suffixEl = fixture . debugElement . query ( By . css ( '.mat-input-suffix' ) ) ;
571+
572+ expect ( prefixEl ) . not . toBeNull ( ) ;
573+ expect ( suffixEl ) . not . toBeNull ( ) ;
574+ expect ( prefixEl . nativeElement . innerText . trim ( ) ) . toEqual ( 'Prefix' ) ;
575+ expect ( suffixEl . nativeElement . innerText . trim ( ) ) . toEqual ( 'Suffix' ) ;
576+ } ) ;
553577} ) ;
554578
555579@Component ( {
@@ -775,6 +799,17 @@ class MdTextareaWithBindings {
775799} )
776800class MdInputContainerMissingMdInputTestController { }
777801
802+ @Component ( {
803+ template : `
804+ <md-input-container>
805+ <div mdPrefix>Prefix</div>
806+ <input mdInput>
807+ <div mdSuffix>Suffix</div>
808+ </md-input-container>
809+ `
810+ } )
811+ class MdInputContainerWithPrefixAndSuffix { }
812+
778813/**
779814 * Gets a RegExp used to detect an angular wrapped error message.
780815 * See https://github.com/angular/angular/issues/8348
0 commit comments