Skip to content

Commit

Permalink
fixup! feat(material-experimental/mdc-form-field): separate out text …
Browse files Browse the repository at this point in the history
…and icon prefixes/suffixes
  • Loading branch information
mmalerba committed Feb 25, 2021
1 parent f798e2f commit 0b6589c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/material-experimental/mdc-input/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ ng_test_library(
"//src/material-experimental/mdc-core",
"//src/material-experimental/mdc-form-field",
"//src/material/core",
"//src/material/icon",
"@npm//@angular/forms",
"@npm//@angular/platform-browser",
],
Expand Down
38 changes: 24 additions & 14 deletions src/material-experimental/mdc-input/input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@ import {
Validators,
} from '@angular/forms';
import {
ErrorStateMatcher,
ShowOnDirtyErrorStateMatcher,
ThemePalette,
} from '@angular/material-experimental/mdc-core';
import {
FloatLabelType,
getMatFormFieldDuplicatedHintError,
getMatFormFieldMissingControlError,
MAT_FORM_FIELD_DEFAULT_OPTIONS,
MatFormField,
MatFormFieldAppearance,
MatFormFieldModule,
FloatLabelType,
} from '@angular/material-experimental/mdc-form-field';
import {
ErrorStateMatcher,
ShowOnDirtyErrorStateMatcher,
ThemePalette,
} from '@angular/material-experimental/mdc-core';
import {MatIconModule} from '@angular/material/icon';
import {By} from '@angular/platform-browser';
import {BrowserAnimationsModule, NoopAnimationsModule} from '@angular/platform-browser/animations';
import {MAT_INPUT_VALUE_ACCESSOR, MatInput, MatInputModule} from './index';
Expand Down Expand Up @@ -701,13 +702,19 @@ describe('MatMdcInput without forms', () => {
const fixture = createComponent(MatInputWithPrefixAndSuffix);
fixture.detectChanges();

const prefixEl = fixture.debugElement.query(By.css('.mat-mdc-form-field-prefix'))!;
const suffixEl = fixture.debugElement.query(By.css('.mat-mdc-form-field-suffix'))!;
const textPrefixEl = fixture.debugElement.query(By.css('.mat-mdc-form-field-text-prefix'))!;
const textSuffixEl = fixture.debugElement.query(By.css('.mat-mdc-form-field-text-suffix'))!;
const iconPrefixEl = fixture.debugElement.query(By.css('.mat-mdc-form-field-icon-prefix'))!;
const iconSuffixEl = fixture.debugElement.query(By.css('.mat-mdc-form-field-icon-suffix'))!;

expect(prefixEl).not.toBeNull();
expect(suffixEl).not.toBeNull();
expect(prefixEl.nativeElement.innerText.trim()).toEqual('Prefix');
expect(suffixEl.nativeElement.innerText.trim()).toEqual('Suffix');
expect(textPrefixEl).not.toBeNull();
expect(textSuffixEl).not.toBeNull();
expect(iconPrefixEl).not.toBeNull();
expect(iconSuffixEl).not.toBeNull();
expect(textPrefixEl.nativeElement.innerText.trim()).toEqual('Prefix');
expect(textSuffixEl.nativeElement.innerText.trim()).toEqual('Suffix');
expect(iconPrefixEl.nativeElement.innerText.trim()).toEqual('favorite');
expect(iconSuffixEl.nativeElement.innerText.trim()).toEqual('favorite');
}));

it('should update empty class when value changes programmatically and OnPush', fakeAsync(() => {
Expand Down Expand Up @@ -1285,6 +1292,7 @@ function configureTestingModule(component: Type<any>, options:
imports: [
FormsModule,
MatFormFieldModule,
MatIconModule,
MatInputModule,
animations ? BrowserAnimationsModule : NoopAnimationsModule,
PlatformModule,
Expand Down Expand Up @@ -1597,9 +1605,11 @@ class MatInputWithFormGroupErrorMessages {
@Component({
template: `
<mat-form-field>
<div matPrefix>Prefix</div>
<mat-icon matIconPrefix>favorite</mat-icon>
<div matTextPrefix>Prefix</div>
<input matInput>
<div matSuffix>Suffix</div>
<div matTextSuffix>Suffix</div>
<mat-icon matIconSuffix>favorite</mat-icon>
</mat-form-field>
`
})
Expand Down

0 comments on commit 0b6589c

Please sign in to comment.