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

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

initial commit

  • Property mode set to 100644
File size: 6.0 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 { ContentContainerComponentHarness, HarnessPredicate, parallel } from '@angular/cdk/testing';
10/** Harness for interacting with a standard mat-toolbar in tests. */
11export class MatToolbarHarness extends ContentContainerComponentHarness {
12 constructor() {
13 super(...arguments);
14 this._getRows = this.locatorForAll(".mat-toolbar-row" /* ROW */);
15 }
16 /**
17 * Gets a `HarnessPredicate` that can be used to search for a `MatToolbarHarness` that meets
18 * certain criteria.
19 * @param options Options for filtering which card instances are considered a match.
20 * @return a `HarnessPredicate` configured with the given options.
21 */
22 static with(options = {}) {
23 return new HarnessPredicate(MatToolbarHarness, options)
24 .addOption('text', options.text, (harness, text) => HarnessPredicate.stringMatches(harness._getText(), text));
25 }
26 /** Whether the toolbar has multiple rows. */
27 hasMultipleRows() {
28 return __awaiter(this, void 0, void 0, function* () {
29 return (yield this.host()).hasClass('mat-toolbar-multiple-rows');
30 });
31 }
32 /** Gets all of the toolbar's content as text. */
33 _getText() {
34 return __awaiter(this, void 0, void 0, function* () {
35 return (yield this.host()).text();
36 });
37 }
38 /** Gets the text of each row in the toolbar. */
39 getRowsAsText() {
40 return __awaiter(this, void 0, void 0, function* () {
41 const rows = yield this._getRows();
42 return parallel(() => rows.length ? rows.map(r => r.text()) : [this._getText()]);
43 });
44 }
45}
46MatToolbarHarness.hostSelector = '.mat-toolbar';
47//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9vbGJhci1oYXJuZXNzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4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XNzLCB0ZXh0KSA9PiBIYXJuZXNzUHJlZGljYXRlLnN0cmluZ01hdGNoZXMoaGFybmVzcy5fZ2V0VGV4dCgpLCB0ZXh0KSk7XG4gIH1cblxuICAvKiogV2hldGhlciB0aGUgdG9vbGJhciBoYXMgbXVsdGlwbGUgcm93cy4gKi9cbiAgYXN5bmMgaGFzTXVsdGlwbGVSb3dzKCk6IFByb21pc2U8Ym9vbGVhbj4ge1xuICAgIHJldHVybiAoYXdhaXQgdGhpcy5ob3N0KCkpLmhhc0NsYXNzKCdtYXQtdG9vbGJhci1tdWx0aXBsZS1yb3dzJyk7XG4gIH1cblxuICAvKiogR2V0cyBhbGwgb2YgdGhlIHRvb2xiYXIncyBjb250ZW50IGFzIHRleHQuICovXG4gIHByaXZhdGUgYXN5bmMgX2dldFRleHQoKTogUHJvbWlzZTxzdHJpbmc+IHtcbiAgICByZXR1cm4gKGF3YWl0IHRoaXMuaG9zdCgpKS50ZXh0KCk7XG4gIH1cblxuICAvKiogR2V0cyB0aGUgdGV4dCBvZiBlYWNoIHJvdyBpbiB0aGUgdG9vbGJhci4gKi9cbiAgYXN5bmMgZ2V0Um93c0FzVGV4dCgpOiBQcm9taXNlPHN0cmluZ1tdPiB7XG4gICAgY29uc3Qgcm93cyA9IGF3YWl0IHRoaXMuX2dldFJvd3MoKTtcbiAgICByZXR1cm4gcGFyYWxsZWwoKCkgPT4gcm93cy5sZW5ndGggPyByb3dzLm1hcChyID0+IHIudGV4dCgpKSA6IFt0aGlzLl9nZXRUZXh0KCldKTtcbiAgfVxufVxuIl19
Note: See TracBrowser for help on using the repository browser.