Skip to content

Commit 5866f84

Browse files
committed
add comments
1 parent 5dbde07 commit 5866f84

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

src/material/tree/testing/node-harness.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,43 @@ import {
1414
import {TreeNodeHarnessFilters} from './tree-harness-filters';
1515
import {coerceBooleanProperty, coerceNumberProperty} from '@angular/cdk/coercion';
1616

17+
/** Harness for interacting with a standard Angular Material tree node. */
1718
export class MatTreeNodeHarness extends ComponentHarness {
19+
/** The selector of the host element of a `MatTreeNode` instance. */
1820
static hostSelector = '.mat-tree-node';
1921

2022
_toggle = this.locatorForOptional('mattreenodetoggle');
2123

24+
/**
25+
* Gets a `HarnessPredicate` that can be used to search for a tree node with specific attributes.
26+
* @param options Options for narrowing the search
27+
* @return a `HarnessPredicate` configured with the given options.
28+
*/
2229
static with(options: TreeNodeHarnessFilters = {}): HarnessPredicate<MatTreeNodeHarness> {
2330
return getNodePredicate(MatTreeNodeHarness, options);
2431
}
2532

33+
/** Whether the tree node is expanded. */
2634
async isExpanded(): Promise<boolean> {
2735
return coerceBooleanProperty(await (await this.host()).getAttribute('aria-expanded'));
2836
}
2937

38+
/** Whether the tree node is disabled. */
3039
async isDisabled(): Promise<boolean> {
3140
return coerceBooleanProperty(await (await this.host()).getProperty('aria-disabled'));
3241
}
3342

43+
/** Gets the level of the tree node.. */
3444
async getLevel(): Promise<number> {
3545
return coerceNumberProperty(await (await this.host()).getAttribute('aria-level'));
3646
}
3747

48+
/** Gets the role of the tree node. 'group' or 'treeitem' */
3849
async getRole(): Promise<string|null> {
3950
return (await this.host()).getAttribute('role');
4051
}
4152

53+
/** Gets the tree node's text. */
4254
async getText(): Promise<string> {
4355
return (await this.host()).text();
4456
}
@@ -51,9 +63,17 @@ export class MatTreeNodeHarness extends ComponentHarness {
5163
}
5264
}
5365

66+
/** Harness for interacting with a standard Angular Material nested tree node. */
5467
export class MatNestedTreeNodeHarness extends MatTreeNodeHarness {
68+
/** The selector for the host element of a `MatNestedTreeNode` instance. */
5569
static hostSelector = '.mat-nested-tree-node';
5670

71+
/**
72+
* Gets a `HarnessPredicate` that can be used to search for
73+
* a nested tree node with specific attributes.
74+
* @param options Options for narrowing the search
75+
* @return a `HarnessPredicate` configured with the given options.
76+
*/
5777
static with(options: TreeNodeHarnessFilters = {}): HarnessPredicate<MatNestedTreeNodeHarness> {
5878
return getNodePredicate(MatNestedTreeNodeHarness, options);
5979
}

src/material/tree/testing/shared.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
MatTreeModule,
77
MatTreeNestedDataSource
88
} from '@angular/material/tree';
9-
import {MatTreeHarness} from '@angular/material/tree/testing/tree-harness';
9+
import {MatTreeHarness} from '@angular/material/tree/testing';
1010
import {ComponentFixture, TestBed} from '@angular/core/testing';
1111
import {HarnessLoader} from '@angular/cdk/testing';
1212
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';

src/material/tree/testing/tree-harness-filters.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,24 @@
88

99
import {BaseHarnessFilters} from '@angular/cdk/testing';
1010

11+
/** A set of criteria that can be used to filter a list of tree harness instances */
1112
export interface TreeHarnessFilters extends BaseHarnessFilters {
1213
}
1314

15+
/** A set of criteria that can be used to filter a list of node harness instances. */
1416
export interface TreeNodeHarnessFilters extends BaseHarnessFilters {
1517
/** Only find instances whose text matches the given value. */
1618
text?: string | RegExp;
19+
1720
/** Only find instances whose state matches the given value. */
1821
disabled?: boolean;
22+
1923
/** Only find instances whose expansion state matches the given value. */
2024
expanded?: boolean;
25+
2126
/** Only find instances whose role matches the given value. */
2227
role?: 'treeitem'|'group';
28+
2329
/** Only find instances whose level matches the given value. */
2430
level?: number;
2531
}

src/material/tree/testing/tree-harness.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88

99
import {ComponentHarness, HarnessPredicate} from '@angular/cdk/testing';
1010
import {
11+
MatNestedTreeNodeHarness,
12+
MatTreeNodeHarness,
1113
TreeHarnessFilters,
1214
TreeNodeHarnessFilters
13-
} from '@angular/material/tree/testing/tree-harness-filters';
14-
import {
15-
MatNestedTreeNodeHarness,
16-
MatTreeNodeHarness
17-
} from '@angular/material/tree/testing/node-harness';
15+
} from '@angular/material/tree/testing';
1816

17+
/** Harness for interacting with a standard mat-tree in tests. */
1918
export class MatTreeHarness extends ComponentHarness {
2019
/** The selector for the host element of a `MatTableHarness` instance. */
2120
static hostSelector = '.mat-tree';
@@ -29,10 +28,12 @@ export class MatTreeHarness extends ComponentHarness {
2928
return new HarnessPredicate(MatTreeHarness, options);
3029
}
3130

31+
/** Gets all of the nodes in the tree. */
3232
async getNodes(filter: TreeNodeHarnessFilters = {}): Promise<MatTreeNodeHarness[]> {
3333
return this.locatorForAll(MatTreeNodeHarness.with(filter))();
3434
}
3535

36+
/** Gets all of the nested nodes in the tree. */
3637
async getNestedNodes(filter: TreeNodeHarnessFilters = {}): Promise<MatNestedTreeNodeHarness[]> {
3738
return this.locatorForAll(MatNestedTreeNodeHarness.with(filter))();
3839
}

0 commit comments

Comments
 (0)