UNPKG

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