source: trip-planner-front/node_modules/@angular/material/esm2015/tree/testing/tree-harness.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 14.6 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { __awaiter } from "tslib";
9import { ComponentHarness, HarnessPredicate, parallel } from '@angular/cdk/testing';
10import { MatTreeNodeHarness } from './node-harness';
11/** Harness for interacting with a standard mat-tree in tests. */
12export class MatTreeHarness extends ComponentHarness {
13 /**
14 * Gets a `HarnessPredicate` that can be used to search for a tree with specific attributes.
15 * @param options Options for narrowing the search
16 * @return a `HarnessPredicate` configured with the given options.
17 */
18 static with(options = {}) {
19 return new HarnessPredicate(MatTreeHarness, options);
20 }
21 /** Gets all of the nodes in the tree. */
22 getNodes(filter = {}) {
23 return __awaiter(this, void 0, void 0, function* () {
24 return this.locatorForAll(MatTreeNodeHarness.with(filter))();
25 });
26 }
27 /**
28 * Gets an object representation for the visible tree structure
29 * If a node is under an unexpanded node it will not be included.
30 * Eg.
31 * Tree (all nodes expanded):
32 * `
33 * <mat-tree>
34 * <mat-tree-node>Node 1<mat-tree-node>
35 * <mat-nested-tree-node>
36 * Node 2
37 * <mat-nested-tree-node>
38 * Node 2.1
39 * <mat-tree-node>
40 * Node 2.1.1
41 * <mat-tree-node>
42 * <mat-nested-tree-node>
43 * <mat-tree-node>
44 * Node 2.2
45 * <mat-tree-node>
46 * <mat-nested-tree-node>
47 * </mat-tree>`
48 *
49 * Tree structure:
50 * {
51 * children: [
52 * {
53 * text: 'Node 1',
54 * children: [
55 * {
56 * text: 'Node 2',
57 * children: [
58 * {
59 * text: 'Node 2.1',
60 * children: [{text: 'Node 2.1.1'}]
61 * },
62 * {text: 'Node 2.2'}
63 * ]
64 * }
65 * ]
66 * }
67 * ]
68 * };
69 */
70 getTreeStructure() {
71 return __awaiter(this, void 0, void 0, function* () {
72 const nodes = yield this.getNodes();
73 const nodeInformation = yield parallel(() => nodes.map(node => {
74 return parallel(() => [node.getLevel(), node.getText(), node.isExpanded()]);
75 }));
76 return this._getTreeStructure(nodeInformation, 1, true);
77 });
78 }
79 /**
80 * Recursively collect the structured text of the tree nodes.
81 * @param nodes A list of tree nodes
82 * @param level The level of nodes that are being accounted for during this iteration
83 * @param parentExpanded Whether the parent of the first node in param nodes is expanded
84 */
85 _getTreeStructure(nodes, level, parentExpanded) {
86 var _a, _b, _c;
87 const result = {};
88 for (let i = 0; i < nodes.length; i++) {
89 const [nodeLevel, text, expanded] = nodes[i];
90 const nextNodeLevel = (_b = (_a = nodes[i + 1]) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : -1;
91 // Return the accumulated value for the current level once we reach a shallower level node
92 if (nodeLevel < level) {
93 return result;
94 }
95 // Skip deeper level nodes during this iteration, they will be picked up in a later iteration
96 if (nodeLevel > level) {
97 continue;
98 }
99 // Only add to representation if it is visible (parent is expanded)
100 if (parentExpanded) {
101 // Collect the data under this node according to the following rules:
102 // 1. If the next node in the list is a sibling of the current node add it to the child list
103 // 2. If the next node is a child of the current node, get the sub-tree structure for the
104 // child and add it under this node
105 // 3. If the next node has a shallower level, we've reached the end of the child nodes for
106 // the current parent.
107 if (nextNodeLevel === level) {
108 this._addChildToNode(result, { text });
109 }
110 else if (nextNodeLevel > level) {
111 let children = (_c = this._getTreeStructure(nodes.slice(i + 1), nextNodeLevel, expanded)) === null || _c === void 0 ? void 0 : _c.children;
112 let child = children ? { text, children } : { text };
113 this._addChildToNode(result, child);
114 }
115 else {
116 this._addChildToNode(result, { text });
117 return result;
118 }
119 }
120 }
121 return result;
122 }
123 _addChildToNode(result, child) {
124 result.children ? result.children.push(child) : result.children = [child];
125 }
126}
127/** The selector for the host element of a `MatTableHarness` instance. */
128MatTreeHarness.hostSelector = '.mat-tree';
129//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9u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U+XG4gICAqICAgPG1hdC10cmVlLW5vZGU+Tm9kZSAxPG1hdC10cmVlLW5vZGU+XG4gICAqICAgPG1hdC1uZXN0ZWQtdHJlZS1ub2RlPlxuICAgKiAgICAgTm9kZSAyXG4gICAqICAgICA8bWF0LW5lc3RlZC10cmVlLW5vZGU+XG4gICAqICAgICAgIE5vZGUgMi4xXG4gICAqICAgICAgIDxtYXQtdHJlZS1ub2RlPlxuICAgKiAgICAgICAgIE5vZGUgMi4xLjFcbiAgICogICAgICAgPG1hdC10cmVlLW5vZGU+XG4gICAqICAgICA8bWF0LW5lc3RlZC10cmVlLW5vZGU+XG4gICAqICAgICA8bWF0LXRyZWUtbm9kZT5cbiAgICogICAgICAgTm9kZSAyLjJcbiAgICogICAgIDxtYXQtdHJlZS1ub2RlPlxuICAgKiAgIDxtYXQtbmVzdGVkLXRyZWUtbm9kZT5cbiAgICogPC9tYXQtdHJlZT5gXG4gICAqXG4gICAqIFRyZWUgc3RydWN0dXJlOlxuICAgKiB7XG4gICAqICBjaGlsZHJlbjogW1xuICAgKiAgICB7XG4gICAqICAgICAgdGV4dDogJ05vZGUgMScsXG4gICAqICAgICAgY2hpbGRyZW46IFtcbiAgICogICAgICAgIHtcbiAgICogICAgICAgICAgdGV4dDogJ05vZGUgMicsXG4gICAqICAgICAgICAgIGNoaWxkcmVuOiBbXG4gICAqICAgICAgICAgICAge1xuICAgKiAgICAgICAgICAgICAgdGV4dDogJ05vZGUgMi4xJyxcbiAgICogICAgICAgICAgICAgIGNoaWxkcmVuOiBbe3RleHQ6ICdOb2RlIDIuMS4xJ31dXG4gICAqICAgICAgICAgICAgfSxcbiAgICogICAgICAgICAgICB7dGV4dDogJ05vZGUgMi4yJ31cbiAgICogICAgICAgICAgXVxuICAgKiAgICAgICAgfVxuICAgKiAgICAgIF1cbiAgICogICAgfVxuICAgKiAgXVxuICAgKiB9O1xuICAgKi9cbiAgYXN5bmMgZ2V0VHJlZVN0cnVjdHVyZSgpOiBQcm9taXNlPF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dXNoKGNoaWxkKSA6IHJlc3VsdC5jaGlsZHJlbiA9IFtjaGlsZF07XG4gIH1cbn1cbiJdfQ==
Note: See TracBrowser for help on using the repository browser.