import { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing'; /** * Harness for interacting with a `mat-option` in tests. * @deprecated Use `MatOptionHarness` from `@angular/material/core/testing` instead. See https://material.angular.io/guide/mdc-migration for information about migrating. * @breaking-change 17.0.0 */ class MatLegacyOptionHarness extends ComponentHarness { constructor() { super(...arguments); /** Element containing the option's text. */ this._text = this.locatorFor('.mat-option-text'); } /** Selector used to locate option instances. */ static { this.hostSelector = '.mat-option'; } /** * Gets a `HarnessPredicate` that can be used to search for a `MatOptionsHarness` 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(MatLegacyOptionHarness, options) .addOption('text', options.text, async (harness, title) => HarnessPredicate.stringMatches(await harness.getText(), title)) .addOption('isSelected', options.isSelected, async (harness, isSelected) => (await harness.isSelected()) === isSelected); } /** Clicks the option. */ async click() { return (await this.host()).click(); } /** Gets the option's label text. */ async getText() { return (await this._text()).text(); } /** Gets whether the option is disabled. */ async isDisabled() { return (await this.host()).hasClass('mat-option-disabled'); } /** Gets whether the option is selected. */ async isSelected() { return (await this.host()).hasClass('mat-selected'); } /** Gets whether the option is active. */ async isActive() { return (await this.host()).hasClass('mat-active'); } /** Gets whether the option is in multiple selection mode. */ async isMultiple() { return (await this.host()).hasClass('mat-option-multiple'); } } /** * Harness for interacting with a `mat-optgroup` in tests. * @deprecated Use `MatOptgroupHarness` from `@angular/material/core/testing` instead. See https://material.angular.io/guide/mdc-migration for information about migrating. * @breaking-change 17.0.0 */ class MatLegacyOptgroupHarness extends ComponentHarness { constructor() { super(...arguments); this._label = this.locatorFor('.mat-optgroup-label'); } /** Selector used to locate option group instances. */ static { this.hostSelector = '.mat-optgroup'; } /** * Gets a `HarnessPredicate` that can be used to search for a `MatOptgroupHarness` 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(MatLegacyOptgroupHarness, options).addOption('labelText', options.labelText, async (harness, title) => HarnessPredicate.stringMatches(await harness.getLabelText(), title)); } /** Gets the option group's label text. */ async getLabelText() { return (await this._label()).text(); } /** Gets whether the option group is disabled. */ async isDisabled() { return (await this.host()).hasClass('mat-optgroup-disabled'); } /** * Gets the options that are inside the group. * @param filter Optionally filters which options are included. */ async getOptions(filter = {}) { return this.locatorForAll(MatLegacyOptionHarness.with(filter))(); } } export { MatLegacyOptgroupHarness, MatLegacyOptionHarness }; //# sourceMappingURL=testing.mjs.map