@@ -20,19 +20,20 @@ import {
2020 Validators ,
2121} from '@angular/forms' ;
2222import {
23+ ErrorStateMatcher ,
24+ ShowOnDirtyErrorStateMatcher ,
25+ ThemePalette ,
26+ } from '@angular/material-experimental/mdc-core' ;
27+ import {
28+ FloatLabelType ,
2329 getMatFormFieldDuplicatedHintError ,
2430 getMatFormFieldMissingControlError ,
2531 MAT_FORM_FIELD_DEFAULT_OPTIONS ,
2632 MatFormField ,
2733 MatFormFieldAppearance ,
2834 MatFormFieldModule ,
29- FloatLabelType ,
3035} from '@angular/material-experimental/mdc-form-field' ;
31- import {
32- ErrorStateMatcher ,
33- ShowOnDirtyErrorStateMatcher ,
34- ThemePalette ,
35- } from '@angular/material-experimental/mdc-core' ;
36+ import { MatIconModule } from '@angular/material/icon' ;
3637import { By } from '@angular/platform-browser' ;
3738import { BrowserAnimationsModule , NoopAnimationsModule } from '@angular/platform-browser/animations' ;
3839import { MAT_INPUT_VALUE_ACCESSOR , MatInput , MatInputModule } from './index' ;
@@ -701,13 +702,19 @@ describe('MatMdcInput without forms', () => {
701702 const fixture = createComponent ( MatInputWithPrefixAndSuffix ) ;
702703 fixture . detectChanges ( ) ;
703704
704- const prefixEl = fixture . debugElement . query ( By . css ( '.mat-mdc-form-field-prefix' ) ) ! ;
705- const suffixEl = fixture . debugElement . query ( By . css ( '.mat-mdc-form-field-suffix' ) ) ! ;
705+ const textPrefixEl = fixture . debugElement . query ( By . css ( '.mat-mdc-form-field-text-prefix' ) ) ! ;
706+ const textSuffixEl = fixture . debugElement . query ( By . css ( '.mat-mdc-form-field-text-suffix' ) ) ! ;
707+ const iconPrefixEl = fixture . debugElement . query ( By . css ( '.mat-mdc-form-field-icon-prefix' ) ) ! ;
708+ const iconSuffixEl = fixture . debugElement . query ( By . css ( '.mat-mdc-form-field-icon-suffix' ) ) ! ;
706709
707- expect ( prefixEl ) . not . toBeNull ( ) ;
708- expect ( suffixEl ) . not . toBeNull ( ) ;
709- expect ( prefixEl . nativeElement . innerText . trim ( ) ) . toEqual ( 'Prefix' ) ;
710- expect ( suffixEl . nativeElement . innerText . trim ( ) ) . toEqual ( 'Suffix' ) ;
710+ expect ( textPrefixEl ) . not . toBeNull ( ) ;
711+ expect ( textSuffixEl ) . not . toBeNull ( ) ;
712+ expect ( iconPrefixEl ) . not . toBeNull ( ) ;
713+ expect ( iconSuffixEl ) . not . toBeNull ( ) ;
714+ expect ( textPrefixEl . nativeElement . innerText . trim ( ) ) . toEqual ( 'Prefix' ) ;
715+ expect ( textSuffixEl . nativeElement . innerText . trim ( ) ) . toEqual ( 'Suffix' ) ;
716+ expect ( iconPrefixEl . nativeElement . innerText . trim ( ) ) . toEqual ( 'favorite' ) ;
717+ expect ( iconSuffixEl . nativeElement . innerText . trim ( ) ) . toEqual ( 'favorite' ) ;
711718 } ) ) ;
712719
713720 it ( 'should update empty class when value changes programmatically and OnPush' , fakeAsync ( ( ) => {
@@ -1285,6 +1292,7 @@ function configureTestingModule(component: Type<any>, options:
12851292 imports : [
12861293 FormsModule ,
12871294 MatFormFieldModule ,
1295+ MatIconModule ,
12881296 MatInputModule ,
12891297 animations ? BrowserAnimationsModule : NoopAnimationsModule ,
12901298 PlatformModule ,
@@ -1597,9 +1605,11 @@ class MatInputWithFormGroupErrorMessages {
15971605@Component ( {
15981606 template : `
15991607 <mat-form-field>
1600- <div matPrefix>Prefix</div>
1608+ <mat-icon matIconPrefix>favorite</mat-icon>
1609+ <div matTextPrefix>Prefix</div>
16011610 <input matInput>
1602- <div matSuffix>Suffix</div>
1611+ <div matTextSuffix>Suffix</div>
1612+ <mat-icon matIconSuffix>favorite</mat-icon>
16031613 </mat-form-field>
16041614 `
16051615} )
0 commit comments