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 { ContentContainerComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
|
---|
10 | /** Harness for interacting with a standard `MatGridTitle` in tests. */
|
---|
11 | export class MatGridTileHarness extends ContentContainerComponentHarness {
|
---|
12 | constructor() {
|
---|
13 | super(...arguments);
|
---|
14 | this._header = this.locatorForOptional(".mat-grid-tile-header" /* HEADER */);
|
---|
15 | this._footer = this.locatorForOptional(".mat-grid-tile-footer" /* FOOTER */);
|
---|
16 | this._avatar = this.locatorForOptional('.mat-grid-avatar');
|
---|
17 | }
|
---|
18 | /**
|
---|
19 | * Gets a `HarnessPredicate` that can be used to search for a `MatGridTileHarness`
|
---|
20 | * that meets certain criteria.
|
---|
21 | * @param options Options for filtering which dialog instances are considered a match.
|
---|
22 | * @return a `HarnessPredicate` configured with the given options.
|
---|
23 | */
|
---|
24 | static with(options = {}) {
|
---|
25 | return new HarnessPredicate(MatGridTileHarness, options)
|
---|
26 | .addOption('headerText', options.headerText, (harness, pattern) => HarnessPredicate.stringMatches(harness.getHeaderText(), pattern))
|
---|
27 | .addOption('footerText', options.footerText, (harness, pattern) => HarnessPredicate.stringMatches(harness.getFooterText(), pattern));
|
---|
28 | }
|
---|
29 | /** Gets the amount of rows that the grid-tile takes up. */
|
---|
30 | getRowspan() {
|
---|
31 | return __awaiter(this, void 0, void 0, function* () {
|
---|
32 | return Number(yield (yield this.host()).getAttribute('rowspan'));
|
---|
33 | });
|
---|
34 | }
|
---|
35 | /** Gets the amount of columns that the grid-tile takes up. */
|
---|
36 | getColspan() {
|
---|
37 | return __awaiter(this, void 0, void 0, function* () {
|
---|
38 | return Number(yield (yield this.host()).getAttribute('colspan'));
|
---|
39 | });
|
---|
40 | }
|
---|
41 | /** Whether the grid-tile has a header. */
|
---|
42 | hasHeader() {
|
---|
43 | return __awaiter(this, void 0, void 0, function* () {
|
---|
44 | return (yield this._header()) !== null;
|
---|
45 | });
|
---|
46 | }
|
---|
47 | /** Whether the grid-tile has a footer. */
|
---|
48 | hasFooter() {
|
---|
49 | return __awaiter(this, void 0, void 0, function* () {
|
---|
50 | return (yield this._footer()) !== null;
|
---|
51 | });
|
---|
52 | }
|
---|
53 | /** Whether the grid-tile has an avatar. */
|
---|
54 | hasAvatar() {
|
---|
55 | return __awaiter(this, void 0, void 0, function* () {
|
---|
56 | return (yield this._avatar()) !== null;
|
---|
57 | });
|
---|
58 | }
|
---|
59 | /** Gets the text of the header if present. */
|
---|
60 | getHeaderText() {
|
---|
61 | return __awaiter(this, void 0, void 0, function* () {
|
---|
62 | // For performance reasons, we do not use "hasHeader" as
|
---|
63 | // we would then need to query twice for the header.
|
---|
64 | const headerEl = yield this._header();
|
---|
65 | return headerEl ? headerEl.text() : null;
|
---|
66 | });
|
---|
67 | }
|
---|
68 | /** Gets the text of the footer if present. */
|
---|
69 | getFooterText() {
|
---|
70 | return __awaiter(this, void 0, void 0, function* () {
|
---|
71 | // For performance reasons, we do not use "hasFooter" as
|
---|
72 | // we would then need to query twice for the footer.
|
---|
73 | const headerEl = yield this._footer();
|
---|
74 | return headerEl ? headerEl.text() : null;
|
---|
75 | });
|
---|
76 | }
|
---|
77 | }
|
---|
78 | /** The selector for the host element of a `MatGridTile` instance. */
|
---|
79 | MatGridTileHarness.hostSelector = '.mat-grid-tile';
|
---|
80 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3JpZC10aWxlLWhhcm5lc3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvZ3JpZC1saXN0L3Rlc3RpbmcvZ3JpZC10aWxlLWhhcm5lc3MudHMiXSwibmFtZ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