/** * @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'; /** Harness for interacting with a native `option` in tests. */ export class MatNativeOptionHarness extends ComponentHarness { /** Selector used to locate option instances. */ static { this.hostSelector = 'select[matNativeControl] option'; } /** * Gets a `HarnessPredicate` that can be used to search for a `MatNativeOptionHarness` that meets * certain criteria. * @param options Options for filtering which option instances are considered a match. * @return a `HarnessPredicate` configured with the given options. */ static with(options = {}) { return new HarnessPredicate(MatNativeOptionHarness, options) .addOption('text', options.text, async (harness, title) => HarnessPredicate.stringMatches(await harness.getText(), title)) .addOption('index', options.index, async (harness, index) => (await harness.getIndex()) === index) .addOption('isSelected', options.isSelected, async (harness, isSelected) => (await harness.isSelected()) === isSelected); } /** Gets the option's label text. */ async getText() { return (await this.host()).getProperty('label'); } /** Index of the option within the native `select` element. */ async getIndex() { return (await this.host()).getProperty('index'); } /** Gets whether the option is disabled. */ async isDisabled() { return (await this.host()).getProperty('disabled'); } /** Gets whether the option is selected. */ async isSelected() { return (await this.host()).getProperty('selected'); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmF0aXZlLW9wdGlvbi1oYXJuZXNzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL21hdGVyaWFsL2lucHV0L3Rlc3RpbmcvbmF0aXZlLW9wdGlvbi1oYXJuZXNzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sRUFBQyxnQkFBZ0IsRUFBRSxnQkFBZ0IsRUFBQyxNQUFNLHNCQUFzQixDQUFDO0FBR3hFLCtEQUErRDtBQUMvRCxNQUFNLE9BQU8sc0JBQXVCLFNBQVEsZ0JBQWdCO0lBQzFELGdEQUFnRDthQUN6QyxpQkF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