/** * @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 { MatListHarnessBase } from './list-harness-base'; import { getListItemPredicate, MatListItemHarnessBase } from './list-item-harness-base'; /** Harness for interacting with a MDC_based selection-list in tests. */ export class MatSelectionListHarness extends MatListHarnessBase { constructor() { super(...arguments); this._itemHarness = MatListOptionHarness; } /** The selector for the host element of a `MatSelectionList` instance. */ static { this.hostSelector = '.mat-mdc-selection-list'; } /** * Gets a `HarnessPredicate` that can be used to search for a selection list with specific * attributes. * @param options Options for filtering which selection list instances are considered a match. * @return a `HarnessPredicate` configured with the given options. */ static with(options = {}) { return new HarnessPredicate(this, options); } /** Whether the selection list is disabled. */ async isDisabled() { return (await (await this.host()).getAttribute('aria-disabled')) === 'true'; } /** * Selects all items matching any of the given filters. * @param filters Filters that specify which items should be selected. */ async selectItems(...filters) { const items = await this._getItems(filters); await parallel(() => items.map(item => item.select())); } /** * Deselects all items matching any of the given filters. * @param filters Filters that specify which items should be deselected. */ async deselectItems(...filters) { const items = await this._getItems(filters); await parallel(() => items.map(item => item.deselect())); } /** Gets all items matching the given list of filters. */ async _getItems(filters) { if (!filters.length) { return this.getItems(); } const matches = await parallel(() => filters.map(filter => this.locatorForAll(MatListOptionHarness.with(filter))())); return matches.reduce((result, current) => [...result, ...current], []); } } /** Harness for interacting with a MDC-based list option. */ export class MatListOptionHarness extends MatListItemHarnessBase { constructor() { super(...arguments); this._beforeCheckbox = this.locatorForOptional('.mdc-list-item__start .mdc-checkbox'); this._beforeRadio = this.locatorForOptional('.mdc-list-item__start .mdc-radio'); } /** The selector for the host element of a `MatListOption` instance. */ static { this.hostSelector = '.mat-mdc-list-option'; } /** * Gets a `HarnessPredicate` that can be used to search for a list option with specific * attributes. * @param options Options for filtering which list option instances are considered a match. * @return a `HarnessPredicate` configured with the given options. */ static with(options = {}) { return getListItemPredicate(this, options).addOption('is selected', options.selected, async (harness, selected) => (await harness.isSelected()) === selected); } /** Gets the position of the checkbox relative to the list option content. */ async getCheckboxPosition() { return (await this._beforeCheckbox()) !== null ? 'before' : 'after'; } /** Gets the position of the radio relative to the list option content. */ async getRadioPosition() { return (await this._beforeRadio()) !== null ? 'before' : 'after'; } /** Whether the list option is selected. */ async isSelected() { return (await (await this.host()).getAttribute('aria-selected')) === 'true'; } /** Focuses the list option. */ async focus() { return (await this.host()).focus(); } /** Blurs the list option. */ async blur() { return (await this.host()).blur(); } /** Whether the list option is focused. */ async isFocused() { return (await this.host()).isFocused(); } /** Toggles the checked state of the checkbox. */ async toggle() { return (await this.host()).click(); } /** * Puts the list option in a checked state by toggling it if it is currently * unchecked, or doing nothing if it is already checked. */ async select() { if (!(await this.isSelected())) { return this.toggle(); } } /** * Puts the list option in an unchecked state by toggling it if it is currently * checked, or doing nothing if it is already unchecked. */ async deselect() { if (await this.isSelected()) { return this.toggle(); } } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VsZWN0aW9uLWxpc3QtaGFybmVzcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9saXN0L3Rlc3Rpbmcvc2VsZWN0aW9uLWxpc3QtaGFybmVzcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQThCLGdCQUFnQixFQUFFLFFBQVEsRUFBQyxNQUFNLHNCQUFzQixDQUFDO0FBRTdGLE9BQU8sRUFBQyxrQkFBa0IsRUFBQyxNQUFNLHFCQUFxQixDQUFDO0FBTXZELE9BQU8sRUFBQyxvQkFBb0IsRUFBRSxzQkFBc0IsRUFBQyxNQUFNLDBCQUEwQixDQUFDO0FBRXRGLHdFQUF3RTtBQUN4RSxNQUFNLE9BQU8sdUJBQXdCLFNBQVEsa0JBSTVD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