/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { ComponentHarness, HarnessPredicate, } from '@angular/cdk/testing'; export class _MatErrorHarnessBase extends ComponentHarness { /** Gets a promise for the error's label text. */ async getText() { return (await this.host()).text(); } static _getErrorPredicate(type, options) { return new HarnessPredicate(type, options).addOption('text', options.text, (harness, text) => HarnessPredicate.stringMatches(harness.getText(), text)); } } /** Harness for interacting with an MDC-based `mat-error` in tests. */ export class MatErrorHarness extends _MatErrorHarnessBase { static { this.hostSelector = '.mat-mdc-form-field-error'; } /** * Gets a `HarnessPredicate` that can be used to search for an error with specific * attributes. * @param options Options for filtering which error instances are considered a match. * @return a `HarnessPredicate` configured with the given options. */ static with(options = {}) { return _MatErrorHarnessBase._getErrorPredicate(this, options); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXJyb3ItaGFybmVzcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9mb3JtLWZpZWxkL3Rlc3RpbmcvZXJyb3ItaGFybmVzcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBRUwsZ0JBQWdCLEVBRWhCLGdCQUFnQixHQUNqQixNQUFNLHNCQUFzQixDQUFDO0FBUTlCLE1BQU0sT0FBZ0Isb0JBQXFCLFNBQVEsZ0JBQWdCO0lBQ2pFLGlEQUFpRDtJQUNqRCxLQUFLLENBQUMsT0FBTztRQUNYLE9BQU8sQ0FBQyxNQUFNLElBQUksQ0FBQyxJQUFJLEVBQUUsQ0FBQyxDQUFDLElBQUksRUFBRSxDQUFDO0lBQ3BDLENBQUM7SUFFUyxNQUFNLENBQUMsa0JBQWtCLENBQ2pDLElBQW9DLEVBQ3BDLE9BQTRCO1FBRTVCLE9B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