/** * @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 { __awaiter } from "tslib"; import { ComponentHarness, HarnessPredicate, parallel } from '@angular/cdk/testing'; import { MatTreeNodeHarness } from './node-harness'; /** Harness for interacting with a standard mat-tree in tests. */ export class MatTreeHarness extends ComponentHarness { /** * Gets a `HarnessPredicate` that can be used to search for a tree with specific attributes. * @param options Options for narrowing the search * @return a `HarnessPredicate` configured with the given options. */ static with(options = {}) { return new HarnessPredicate(MatTreeHarness, options); } /** Gets all of the nodes in the tree. */ getNodes(filter = {}) { return __awaiter(this, void 0, void 0, function* () { return this.locatorForAll(MatTreeNodeHarness.with(filter))(); }); } /** * Gets an object representation for the visible tree structure * If a node is under an unexpanded node it will not be included. * Eg. * Tree (all nodes expanded): * ` * * Node 1 * * Node 2 * * Node 2.1 * * Node 2.1.1 * * * * Node 2.2 * * * ` * * Tree structure: * { * children: [ * { * text: 'Node 1', * children: [ * { * text: 'Node 2', * children: [ * { * text: 'Node 2.1', * children: [{text: 'Node 2.1.1'}] * }, * {text: 'Node 2.2'} * ] * } * ] * } * ] * }; */ getTreeStructure() { return __awaiter(this, void 0, void 0, function* () { const nodes = yield this.getNodes(); const nodeInformation = yield parallel(() => nodes.map(node => { return parallel(() => [node.getLevel(), node.getText(), node.isExpanded()]); })); return this._getTreeStructure(nodeInformation, 1, true); }); } /** * Recursively collect the structured text of the tree nodes. * @param nodes A list of tree nodes * @param level The level of nodes that are being accounted for during this iteration * @param parentExpanded Whether the parent of the first node in param nodes is expanded */ _getTreeStructure(nodes, level, parentExpanded) { var _a, _b, _c; const result = {}; for (let i = 0; i < nodes.length; i++) { const [nodeLevel, text, expanded] = nodes[i]; const nextNodeLevel = (_b = (_a = nodes[i + 1]) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : -1; // Return the accumulated value for the current level once we reach a shallower level node if (nodeLevel < level) { return result; } // Skip deeper level nodes during this iteration, they will be picked up in a later iteration if (nodeLevel > level) { continue; } // Only add to representation if it is visible (parent is expanded) if (parentExpanded) { // Collect the data under this node according to the following rules: // 1. If the next node in the list is a sibling of the current node add it to the child list // 2. If the next node is a child of the current node, get the sub-tree structure for the // child and add it under this node // 3. If the next node has a shallower level, we've reached the end of the child nodes for // the current parent. if (nextNodeLevel === level) { this._addChildToNode(result, { text }); } else if (nextNodeLevel > level) { let children = (_c = this._getTreeStructure(nodes.slice(i + 1), nextNodeLevel, expanded)) === null || _c === void 0 ? void 0 : _c.children; let child = children ? { text, children } : { text }; this._addChildToNode(result, child); } else { this._addChildToNode(result, { text }); return result; } } } return result; } _addChildToNode(result, child) { result.children ? result.children.push(child) : result.children = [child]; } } /** The selector for the host element of a `MatTableHarness` instance. */ MatTreeHarness.hostSelector = '.mat-tree'; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJlZS1oYXJuZXNzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL21hdGVyaWFsL3RyZWUvdGVzdGluZy90cmVlLWhhcm5lc3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HOztBQUVILE9BQU8sRUFBQyxnQkFBZ0IsRUFBRSxnQkFBZ0IsRUFBRSxRQUFRLEVBQUMsTUFBTSxzQkFBc0IsQ0FBQztBQUNsRixPQUFPLEVBQUMsa0JBQWtCLEVBQUMsTUFBTSxnQkFBZ0IsQ0FBQztBQVFsRCxpRUFBaUU7QUFDakUsTUFBTSxPQUFPLGNBQWUsU0FBUSxnQkFBZ0I7SUFJbEQ7Ozs7T0FJRztJQUNILE1BQU0sQ0FBQyxJQUFJLENBQUMsVUFBOEIsRUFBRTtRQUMxQyxPQUFPLElBQUksZ0JBQWdCLENBQUMsY0FBYyxFQUFFLE9BQU8sQ0FBQyxDQUFDO0lBQ3ZELENBQUM7SUFFRCx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