Skip to content

Commit

Permalink
fixup! fix(material/form-field): allow getting harness by validity
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba committed Dec 12, 2022
1 parent 3475e30 commit 706ba7e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
Expand Up @@ -15,5 +15,5 @@ export interface FormFieldHarnessFilters extends BaseHarnessFilters {
/** Filters based on whether the form field has error messages. */
hasErrors?: boolean;
/** Filters based on whether the form field value is valid. */
valid?: boolean;
isValid?: boolean;
}
2 changes: 1 addition & 1 deletion src/material/form-field/testing/form-field-harness.ts
Expand Up @@ -251,7 +251,7 @@ export class MatFormFieldHarness extends _MatFormFieldHarnessBase<
)
.addOption(
'valid',
options.valid,
options.isValid,
async (harness, valid) => (await harness.isControlValid()) === valid,
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/material/form-field/testing/shared.spec.ts
Expand Up @@ -198,13 +198,13 @@ export function runHarnessTests(
});

it('should be able to get form-field by validity', async () => {
let invalid = await loader.getAllHarnesses(formFieldHarness.with({valid: false}));
let invalid = await loader.getAllHarnesses(formFieldHarness.with({isValid: false}));
expect(invalid.length).toBe(0);

fixture.componentInstance.requiredControl.setValue('');
dispatchFakeEvent(fixture.nativeElement.querySelector('#with-errors input'), 'blur');

invalid = await loader.getAllHarnesses(formFieldHarness.with({valid: false}));
invalid = await loader.getAllHarnesses(formFieldHarness.with({isValid: false}));
expect(invalid.length).toBe(1);
});

Expand Down
Expand Up @@ -60,7 +60,7 @@ export class MatLegacyFormFieldHarness extends _MatFormFieldHarnessBase<
)
.addOption(
'valid',
options.valid,
options.isValid,
async (harness, valid) => (await harness.isControlValid()) === valid,
);
}
Expand Down
1 change: 1 addition & 0 deletions tools/public_api_guard/material/form-field-testing.md
Expand Up @@ -28,6 +28,7 @@ export type FormFieldControlHarness = MatInputHarness | MatSelectHarness | MatDa
export interface FormFieldHarnessFilters extends BaseHarnessFilters {
floatingLabelText?: string | RegExp;
hasErrors?: boolean;
isValid?: boolean;
}

// @public
Expand Down

0 comments on commit 706ba7e

Please sign in to comment.