/** * @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, parallel, } from '@angular/cdk/testing'; import { MatDividerHarness } from '@angular/material/divider/testing'; import { MatLegacySubheaderHarness } from './list-item-harness-base'; /** * Shared behavior among the harnesses for the various `MatList` flavors. * @template T A constructor type for a list item harness type used by this list harness. * @template C The list item harness type that `T` constructs. * @template F The filter type used filter list item harness of type `C`. * @docs-private * @deprecated Use `class` from `@angular/material/list/testing` instead. See https://material.angular.io/guide/mdc-migration for information about migrating. * @breaking-change 17.0.0 */ export class MatLegacyListHarnessBase extends ComponentHarness { /** * Gets a list of harnesses representing the items in this list. * @param filters Optional filters used to narrow which harnesses are included * @return The list of items matching the given filters. */ async getItems(filters) { return this.locatorForAll(this._itemHarness.with(filters))(); } /** * Gets a list of `ListSection` representing the list items grouped by subheaders. If the list has * no subheaders it is represented as a single `ListSection` with an undefined `heading` property. * @param filters Optional filters used to narrow which list item harnesses are included * @return The list of items matching the given filters, grouped into sections by subheader. */ async getItemsGroupedBySubheader(filters) { const listSections = []; let currentSection = { items: [] }; const itemsAndSubheaders = await this.getItemsWithSubheadersAndDividers({ item: filters, divider: false, }); for (const itemOrSubheader of itemsAndSubheaders) { if (itemOrSubheader instanceof MatLegacySubheaderHarness) { if (currentSection.heading !== undefined || currentSection.items.length) { listSections.push(currentSection); } currentSection = { heading: itemOrSubheader.getText(), items: [] }; } else { currentSection.items.push(itemOrSubheader); } } if (currentSection.heading !== undefined || currentSection.items.length || !listSections.length) { listSections.push(currentSection); } // Concurrently wait for all sections to resolve their heading if present. return parallel(() => listSections.map(async (s) => ({ items: s.items, heading: await s.heading }))); } /** * Gets a list of sub-lists representing the list items grouped by dividers. If the list has no * dividers it is represented as a list with a single sub-list. * @param filters Optional filters used to narrow which list item harnesses are included * @return The list of items matching the given filters, grouped into sub-lists by divider. */ async getItemsGroupedByDividers(filters) { const listSections = [[]]; const itemsAndDividers = await this.getItemsWithSubheadersAndDividers({ item: filters, subheader: false, }); for (const itemOrDivider of itemsAndDividers) { if (itemOrDivider instanceof MatDividerHarness) { listSections.push([]); } else { listSections[listSections.length - 1].push(itemOrDivider); } } return listSections; } async getItemsWithSubheadersAndDividers(filters = {}) { const query = []; if (filters.item !== false) { query.push(this._itemHarness.with(filters.item || {})); } if (filters.subheader !== false) { query.push(MatLegacySubheaderHarness.with(filters.subheader)); } if (filters.divider !== false) { query.push(MatDividerHarness.with(filters.divider)); } return this.locatorForAll(...query)(); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlzdC1oYXJuZXNzLWJhc2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvbGVnYWN5LWxpc3QvdGVzdGluZy9saXN0LWhhcm5lc3MtYmFzZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQ0wsZ0JBQWdCLEVBR2hCLFFBQVEsR0FDVCxNQUFNLHNCQUFzQixDQUFDO0FBQzlCLE9BQU8sRUFBd0IsaUJBQWlCLEVBQUMsTUFBTSxtQ0FBbUMsQ0FBQztBQUszRixPQUFPLEVBQUMseUJBQXlCLEVBQUMsTUFBTSwwQkFBMEIsQ0FBQztBQWVuRTs7Ozs7Ozs7R0FRRztBQUNILE1BQU0sT0FBZ0Isd0JBSXBCLFNBQVEsZ0JBQWdCO0lBR3hCOzs7O09BSUc7SUFDSCxLQUFLLENBQUMsUUFBUSxDQUFDLE9BQVc7UUFDeEIsT0FBTyxJQUFJLENBQUMsYUFBYSxDQUFDLElBQUksQ0FBQyxZQUFZLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUFDLEVBQUUsQ0FBQztJQUMvRCxDQUFDO0lBRUQ7Ozs7O09BS0c7SUFDSCxLQUFLLENBQUMsME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