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 | */
|
---|
8 | import { __awaiter } from "tslib";
|
---|
9 | import { ComponentHarness, HarnessPredicate, parallel, } from '@angular/cdk/testing';
|
---|
10 | import { MatCellHarness, MatHeaderCellHarness, MatFooterCellHarness } from './cell-harness';
|
---|
11 | export class _MatRowHarnessBase extends ComponentHarness {
|
---|
12 | /** Gets a list of `MatCellHarness` for all cells in the row. */
|
---|
13 | getCells(filter = {}) {
|
---|
14 | return __awaiter(this, void 0, void 0, function* () {
|
---|
15 | return this.locatorForAll(this._cellHarness.with(filter))();
|
---|
16 | });
|
---|
17 | }
|
---|
18 | /** Gets the text of the cells in the row. */
|
---|
19 | getCellTextByIndex(filter = {}) {
|
---|
20 | return __awaiter(this, void 0, void 0, function* () {
|
---|
21 | const cells = yield this.getCells(filter);
|
---|
22 | return parallel(() => cells.map(cell => cell.getText()));
|
---|
23 | });
|
---|
24 | }
|
---|
25 | /** Gets the text inside the row organized by columns. */
|
---|
26 | getCellTextByColumnName() {
|
---|
27 | return __awaiter(this, void 0, void 0, function* () {
|
---|
28 | const output = {};
|
---|
29 | const cells = yield this.getCells();
|
---|
30 | const cellsData = yield parallel(() => cells.map(cell => {
|
---|
31 | return parallel(() => [cell.getColumnName(), cell.getText()]);
|
---|
32 | }));
|
---|
33 | cellsData.forEach(([columnName, text]) => output[columnName] = text);
|
---|
34 | return output;
|
---|
35 | });
|
---|
36 | }
|
---|
37 | }
|
---|
38 | /** Harness for interacting with a standard Angular Material table row. */
|
---|
39 | export class MatRowHarness extends _MatRowHarnessBase {
|
---|
40 | constructor() {
|
---|
41 | super(...arguments);
|
---|
42 | this._cellHarness = MatCellHarness;
|
---|
43 | }
|
---|
44 | /**
|
---|
45 | * Gets a `HarnessPredicate` that can be used to search for a table row with specific attributes.
|
---|
46 | * @param options Options for narrowing the search
|
---|
47 | * @return a `HarnessPredicate` configured with the given options.
|
---|
48 | */
|
---|
49 | static with(options = {}) {
|
---|
50 | return new HarnessPredicate(MatRowHarness, options);
|
---|
51 | }
|
---|
52 | }
|
---|
53 | /** The selector for the host element of a `MatRowHarness` instance. */
|
---|
54 | MatRowHarness.hostSelector = '.mat-row';
|
---|
55 | /** Harness for interacting with a standard Angular Material table header row. */
|
---|
56 | export class MatHeaderRowHarness extends _MatRowHarnessBase {
|
---|
57 | constructor() {
|
---|
58 | super(...arguments);
|
---|
59 | this._cellHarness = MatHeaderCellHarness;
|
---|
60 | }
|
---|
61 | /**
|
---|
62 | * Gets a `HarnessPredicate` that can be used to search for
|
---|
63 | * a table header row with specific attributes.
|
---|
64 | * @param options Options for narrowing the search
|
---|
65 | * @return a `HarnessPredicate` configured with the given options.
|
---|
66 | */
|
---|
67 | static with(options = {}) {
|
---|
68 | return new HarnessPredicate(MatHeaderRowHarness, options);
|
---|
69 | }
|
---|
70 | }
|
---|
71 | /** The selector for the host element of a `MatHeaderRowHarness` instance. */
|
---|
72 | MatHeaderRowHarness.hostSelector = '.mat-header-row';
|
---|
73 | /** Harness for interacting with a standard Angular Material table footer row. */
|
---|
74 | export class MatFooterRowHarness extends _MatRowHarnessBase {
|
---|
75 | constructor() {
|
---|
76 | super(...arguments);
|
---|
77 | this._cellHarness = MatFooterCellHarness;
|
---|
78 | }
|
---|
79 | /**
|
---|
80 | * Gets a `HarnessPredicate` that can be used to search for
|
---|
81 | * a table footer row cell with specific attributes.
|
---|
82 | * @param options Options for narrowing the search
|
---|
83 | * @return a `HarnessPredicate` configured with the given options.
|
---|
84 | */
|
---|
85 | static with(options = {}) {
|
---|
86 | return new HarnessPredicate(MatFooterRowHarness, options);
|
---|
87 | }
|
---|
88 | }
|
---|
89 | /** The selector for the host element of a `MatFooterRowHarness` instance. */
|
---|
90 | MatFooterRowHarness.hostSelector = '.mat-footer-row';
|
---|
91 | //# sourceMappingURL=data:application/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