@@ -20,19 +20,20 @@ import {
20
20
Validators ,
21
21
} from '@angular/forms' ;
22
22
import {
23
+ ErrorStateMatcher ,
24
+ ShowOnDirtyErrorStateMatcher ,
25
+ ThemePalette ,
26
+ } from '@angular/material-experimental/mdc-core' ;
27
+ import {
28
+ FloatLabelType ,
23
29
getMatFormFieldDuplicatedHintError ,
24
30
getMatFormFieldMissingControlError ,
25
31
MAT_FORM_FIELD_DEFAULT_OPTIONS ,
26
32
MatFormField ,
27
33
MatFormFieldAppearance ,
28
34
MatFormFieldModule ,
29
- FloatLabelType ,
30
35
} 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' ;
36
37
import { By } from '@angular/platform-browser' ;
37
38
import { BrowserAnimationsModule , NoopAnimationsModule } from '@angular/platform-browser/animations' ;
38
39
import { MAT_INPUT_VALUE_ACCESSOR , MatInput , MatInputModule } from './index' ;
@@ -701,13 +702,19 @@ describe('MatMdcInput without forms', () => {
701
702
const fixture = createComponent ( MatInputWithPrefixAndSuffix ) ;
702
703
fixture . detectChanges ( ) ;
703
704
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' ) ) ! ;
706
709
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' ) ;
711
718
} ) ) ;
712
719
713
720
it ( 'should update empty class when value changes programmatically and OnPush' , fakeAsync ( ( ) => {
@@ -1285,6 +1292,7 @@ function configureTestingModule(component: Type<any>, options:
1285
1292
imports : [
1286
1293
FormsModule ,
1287
1294
MatFormFieldModule ,
1295
+ MatIconModule ,
1288
1296
MatInputModule ,
1289
1297
animations ? BrowserAnimationsModule : NoopAnimationsModule ,
1290
1298
PlatformModule ,
@@ -1597,9 +1605,11 @@ class MatInputWithFormGroupErrorMessages {
1597
1605
@Component ( {
1598
1606
template : `
1599
1607
<mat-form-field>
1600
- <div matPrefix>Prefix</div>
1608
+ <mat-icon matIconPrefix>favorite</mat-icon>
1609
+ <div matTextPrefix>Prefix</div>
1601
1610
<input matInput>
1602
- <div matSuffix>Suffix</div>
1611
+ <div matTextSuffix>Suffix</div>
1612
+ <mat-icon matIconSuffix>favorite</mat-icon>
1603
1613
</mat-form-field>
1604
1614
`
1605
1615
} )
0 commit comments