/** * @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 { MatSubheaderHarness } 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 */ export class MatListHarnessBase 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 MatSubheaderHarness) { 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(MatSubheaderHarness.with(filters.subheader)); } if (filters.divider !== false) { query.push(MatDividerHarness.with(filters.divider)); } return this.locatorForAll(...query)(); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlzdC1oYXJuZXNzLWJhc2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvbGlzdC90ZXN0aW5nL2xpc3QtaGFybmVzcy1iYXNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sRUFDTCxnQkFBZ0IsRUFHaEIsUUFBUSxHQUNULE1BQU0sc0JBQXNCLENBQUM7QUFDOUIsT0FBTyxFQUF3QixpQkFBaUIsRUFBQyxNQUFNLG1DQUFtQyxDQUFDO0FBRTNGLE9BQU8sRUFBQyxtQkFBbUIsRUFBQyxNQUFNLDBCQUEwQixDQUFDO0FBVzdEOzs7Ozs7R0FNRztBQUNILE1BQU0sT0FBZ0Isa0JBSXBCLFNBQVEsZ0JBQWdCO0lBR3hCOzs7O09BSUc7SUFDSCxLQUFLLENBQUMsUUFBUSxDQUFDLE9BQVc7UUFDeEIsT0FBTyxJQUFJLENBQUMsYUFBYSxDQUFDLElBQUksQ0FBQyxZQUFZLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUFDLEVBQUUsQ0FBQztJQUMvRCxDQUFDO0lBRUQ7Ozs7O09BS0c7SUFDSCxLQUFLLENBQUMsMEJBQTBCLENBQUMsT0FBVztRQUUxQyxNQUFNLFlBQVksR0FBYyxFQUFFLENBQUM7UUFDbkMsSUFBSSxjQUFjLEdBQVksRUFBQyxLQU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