/** * @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 { HarnessPredicate, parallel } from '@angular/cdk/testing'; import { MatFormFieldControlHarness } from '@angular/material/form-field/testing/control'; /** Harness for interacting with a standard Material inputs in tests. */ export class MatInputHarness extends MatFormFieldControlHarness { // TODO: We do not want to handle `select` elements with `matNativeControl` because // not all methods of this harness work reasonably for native select elements. // For more details. See: https://github.com/angular/components/pull/18221. static { this.hostSelector = '[matInput], input[matNativeControl], textarea[matNativeControl]'; } /** * Gets a `HarnessPredicate` that can be used to search for a `MatInputHarness` that meets * certain criteria. * @param options Options for filtering which input instances are considered a match. * @return a `HarnessPredicate` configured with the given options. */ static with(options = {}) { return new HarnessPredicate(MatInputHarness, options) .addOption('value', options.value, (harness, value) => { return HarnessPredicate.stringMatches(harness.getValue(), value); }) .addOption('placeholder', options.placeholder, (harness, placeholder) => { return HarnessPredicate.stringMatches(harness.getPlaceholder(), placeholder); }); } /** Whether the input is disabled. */ async isDisabled() { return (await this.host()).getProperty('disabled'); } /** Whether the input is required. */ async isRequired() { return (await this.host()).getProperty('required'); } /** Whether the input is readonly. */ async isReadonly() { return (await this.host()).getProperty('readOnly'); } /** Gets the value of the input. */ async getValue() { // The "value" property of the native input is never undefined. return await (await this.host()).getProperty('value'); } /** Gets the name of the input. */ async getName() { // The "name" property of the native input is never undefined. return await (await this.host()).getProperty('name'); } /** * Gets the type of the input. Returns "textarea" if the input is * a textarea. */ async getType() { // The "type" property of the native input is never undefined. return await (await this.host()).getProperty('type'); } /** Gets the placeholder of the input. */ async getPlaceholder() { const host = await this.host(); const [nativePlaceholder, fallback] = await parallel(() => [ host.getProperty('placeholder'), host.getAttribute('data-placeholder'), ]); return nativePlaceholder || fallback || ''; } /** Gets the id of the input. */ async getId() { // The input directive always assigns a unique id to the input in // case no id has been explicitly specified. return await (await this.host()).getProperty('id'); } /** * Focuses the input and returns a promise that indicates when the * action is complete. */ async focus() { return (await this.host()).focus(); } /** * Blurs the input and returns a promise that indicates when the * action is complete. */ async blur() { return (await this.host()).blur(); } /** Whether the input is focused. */ async isFocused() { return (await this.host()).isFocused(); } /** * Sets the value of the input. The value will be set by simulating * keypresses that correspond to the given value. */ async setValue(newValue) { const inputEl = await this.host(); await inputEl.clear(); // We don't want to send keys for the value if the value is an empty // string in order to clear the value. Sending keys with an empty string // still results in unnecessary focus events. if (newValue) { await inputEl.sendKeys(newValue); } // Some input types won't respond to key presses (e.g. `color`) so to be sure that the // value is set, we also set the property after the keyboard sequence. Note that we don't // want to do it before, because it can cause the value to be entered twice. await inputEl.setInputValue(newValue); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5wdXQtaGFybmVzcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9pbnB1dC90ZXN0aW5nL2lucHV0LWhhcm5lc3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUFDLGdCQUFnQixFQUFFLFFBQVEsRUFBQyxNQUFNLHNCQUFzQixDQUFDO0FBQ2hFLE9BQU8sRUFBQywwQkFBMEIsRUFBQyxNQUFNLDhDQUE4QyxDQUFDO0FBR3hGLHdFQUF3RTtBQUN4RSxNQUFNLE9BQU8sZUFBZ0IsU0FBUSwwQkFBMEI7SUFDN0QsbUZBQW1GO0lBQ25GLDhFQUE4RTtJQUM5RSwyRUFBMkU7YUFDcEUsaUJBQVksR0FBRyxpRUFBaUUsQ0FBQztJQUV4Rjs7Ozs7T0FLRztJQUNILE1BQU0sQ0FBQyxJQUFJLENBQUMsVUFBK0IsRUFBRTtRQUMzQyxPQUFPLElBQUksZ0JBQWdCLENBQUMsZUFBZSxFQUFFLE9BQU8sQ0FBQzthQUNsRCxTQUFTLENBQUMsT0FBTyxFQUFFLE9B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