| 17 | |
| 18 | /** Harness for interacting with a standard `MatGridTitle` in tests. */ |
| 19 | export class MatGridTileHarness extends ContentContainerComponentHarness<MatGridTileSection> { |
| 20 | /** The selector for the host element of a `MatGridTile` instance. */ |
| 21 | static hostSelector = '.mat-grid-tile'; |
| 22 | |
| 23 | /** |
| 24 | * Gets a `HarnessPredicate` that can be used to search for a `MatGridTileHarness` |
| 25 | * that meets certain criteria. |
| 26 | * @param options Options for filtering which dialog instances are considered a match. |
| 27 | * @return a `HarnessPredicate` configured with the given options. |
| 28 | */ |
| 29 | static with(options: GridTileHarnessFilters = {}): HarnessPredicate<MatGridTileHarness> { |
| 30 | return new HarnessPredicate(MatGridTileHarness, options) |
| 31 | .addOption('headerText', options.headerText, (harness, pattern) => |
| 32 | HarnessPredicate.stringMatches(harness.getHeaderText(), pattern), |
| 33 | ) |
| 34 | .addOption('footerText', options.footerText, (harness, pattern) => |
| 35 | HarnessPredicate.stringMatches(harness.getFooterText(), pattern), |
| 36 | ); |
| 37 | } |
| 38 | |
| 39 | private _header = this.locatorForOptional(MatGridTileSection.HEADER); |
| 40 | private _footer = this.locatorForOptional(MatGridTileSection.FOOTER); |
| 41 | private _avatar = this.locatorForOptional('.mat-grid-avatar'); |
| 42 | |
| 43 | /** Gets the amount of rows that the grid-tile takes up. */ |
| 44 | async getRowspan(): Promise<number> { |
| 45 | return Number(await (await this.host()).getAttribute('rowspan')); |
| 46 | } |
| 47 | |
| 48 | /** Gets the amount of columns that the grid-tile takes up. */ |
| 49 | async getColspan(): Promise<number> { |
| 50 | return Number(await (await this.host()).getAttribute('colspan')); |
| 51 | } |
| 52 | |
| 53 | /** Whether the grid-tile has a header. */ |
| 54 | async hasHeader(): Promise<boolean> { |
| 55 | return (await this._header()) !== null; |
| 56 | } |
| 57 | |
| 58 | /** Whether the grid-tile has a footer. */ |
| 59 | async hasFooter(): Promise<boolean> { |
| 60 | return (await this._footer()) !== null; |
| 61 | } |
| 62 | |
| 63 | /** Whether the grid-tile has an avatar. */ |
| 64 | async hasAvatar(): Promise<boolean> { |
| 65 | return (await this._avatar()) !== null; |
| 66 | } |
| 67 | |
| 68 | /** Gets the text of the header if present. */ |
| 69 | async getHeaderText(): Promise<string | null> { |
| 70 | // For performance reasons, we do not use "hasHeader" as |
| 71 | // we would then need to query twice for the header. |
| 72 | const headerEl = await this._header(); |
| 73 | return headerEl ? headerEl.text() : null; |
| 74 | } |
| 75 | |
| 76 | /** Gets the text of the footer if present. */ |
nothing calls this directly
no test coverage detected
searching dependent graphs…