1 | import { __awaiter } from 'tslib';
|
---|
2 | import { ContentContainerComponentHarness, HarnessPredicate, parallel } from '@angular/cdk/testing';
|
---|
3 |
|
---|
4 | /**
|
---|
5 | * @license
|
---|
6 | * Copyright Google LLC All Rights Reserved.
|
---|
7 | *
|
---|
8 | * Use of this source code is governed by an MIT-style license that can be
|
---|
9 | * found in the LICENSE file at https://angular.io/license
|
---|
10 | */
|
---|
11 | /** Harness for interacting with a standard mat-toolbar in tests. */
|
---|
12 | class MatToolbarHarness extends ContentContainerComponentHarness {
|
---|
13 | constructor() {
|
---|
14 | super(...arguments);
|
---|
15 | this._getRows = this.locatorForAll(".mat-toolbar-row" /* ROW */);
|
---|
16 | }
|
---|
17 | /**
|
---|
18 | * Gets a `HarnessPredicate` that can be used to search for a `MatToolbarHarness` that meets
|
---|
19 | * certain criteria.
|
---|
20 | * @param options Options for filtering which card instances are considered a match.
|
---|
21 | * @return a `HarnessPredicate` configured with the given options.
|
---|
22 | */
|
---|
23 | static with(options = {}) {
|
---|
24 | return new HarnessPredicate(MatToolbarHarness, options)
|
---|
25 | .addOption('text', options.text, (harness, text) => HarnessPredicate.stringMatches(harness._getText(), text));
|
---|
26 | }
|
---|
27 | /** Whether the toolbar has multiple rows. */
|
---|
28 | hasMultipleRows() {
|
---|
29 | return __awaiter(this, void 0, void 0, function* () {
|
---|
30 | return (yield this.host()).hasClass('mat-toolbar-multiple-rows');
|
---|
31 | });
|
---|
32 | }
|
---|
33 | /** Gets all of the toolbar's content as text. */
|
---|
34 | _getText() {
|
---|
35 | return __awaiter(this, void 0, void 0, function* () {
|
---|
36 | return (yield this.host()).text();
|
---|
37 | });
|
---|
38 | }
|
---|
39 | /** Gets the text of each row in the toolbar. */
|
---|
40 | getRowsAsText() {
|
---|
41 | return __awaiter(this, void 0, void 0, function* () {
|
---|
42 | const rows = yield this._getRows();
|
---|
43 | return parallel(() => rows.length ? rows.map(r => r.text()) : [this._getText()]);
|
---|
44 | });
|
---|
45 | }
|
---|
46 | }
|
---|
47 | MatToolbarHarness.hostSelector = '.mat-toolbar';
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * @license
|
---|
51 | * Copyright Google LLC All Rights Reserved.
|
---|
52 | *
|
---|
53 | * Use of this source code is governed by an MIT-style license that can be
|
---|
54 | * found in the LICENSE file at https://angular.io/license
|
---|
55 | */
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * @license
|
---|
59 | * Copyright Google LLC All Rights Reserved.
|
---|
60 | *
|
---|
61 | * Use of this source code is governed by an MIT-style license that can be
|
---|
62 | * found in the LICENSE file at https://angular.io/license
|
---|
63 | */
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * @license
|
---|
67 | * Copyright Google LLC All Rights Reserved.
|
---|
68 | *
|
---|
69 | * Use of this source code is governed by an MIT-style license that can be
|
---|
70 | * found in the LICENSE file at https://angular.io/license
|
---|
71 | */
|
---|
72 |
|
---|
73 | export { MatToolbarHarness };
|
---|
74 | //# sourceMappingURL=testing.js.map
|
---|