|
6 | 6 | * found in the LICENSE file at https://angular.io/license
|
7 | 7 | */
|
8 | 8 |
|
9 |
| -import {ComponentHarness, HarnessPredicate} from '@angular/cdk/testing'; |
| 9 | +import { |
| 10 | + AsyncFactoryFn, |
| 11 | + ComponentHarness, |
| 12 | + HarnessPredicate, |
| 13 | + TestElement, |
| 14 | +} from '@angular/cdk/testing'; |
10 | 15 | import {TooltipHarnessFilters} from './tooltip-harness-filters';
|
11 | 16 |
|
12 |
| -/** Harness for interacting with a standard mat-tooltip in tests. */ |
13 |
| -export class MatTooltipHarness extends ComponentHarness { |
14 |
| - private _optionalPanel = this.documentRootLocatorFactory().locatorForOptional('.mat-tooltip'); |
15 |
| - static hostSelector = '.mat-tooltip-trigger'; |
16 |
| - |
17 |
| - /** |
18 |
| - * Gets a `HarnessPredicate` that can be used to search |
19 |
| - * for a tooltip trigger with specific attributes. |
20 |
| - * @param options Options for narrowing the search. |
21 |
| - * @return a `HarnessPredicate` configured with the given options. |
22 |
| - */ |
23 |
| - static with(options: TooltipHarnessFilters = {}): HarnessPredicate<MatTooltipHarness> { |
24 |
| - return new HarnessPredicate(MatTooltipHarness, options); |
25 |
| - } |
| 17 | +export abstract class _MatTooltipHarnessBase extends ComponentHarness { |
| 18 | + protected abstract _optionalPanel: AsyncFactoryFn<TestElement | null>; |
26 | 19 |
|
27 | 20 | /** Shows the tooltip. */
|
28 | 21 | async show(): Promise<void> {
|
@@ -59,3 +52,19 @@ export class MatTooltipHarness extends ComponentHarness {
|
59 | 52 | return panel ? panel.text() : '';
|
60 | 53 | }
|
61 | 54 | }
|
| 55 | + |
| 56 | +/** Harness for interacting with a standard mat-tooltip in tests. */ |
| 57 | +export class MatTooltipHarness extends _MatTooltipHarnessBase { |
| 58 | + protected _optionalPanel = this.documentRootLocatorFactory().locatorForOptional('.mat-tooltip'); |
| 59 | + static hostSelector = '.mat-tooltip-trigger'; |
| 60 | + |
| 61 | + /** |
| 62 | + * Gets a `HarnessPredicate` that can be used to search |
| 63 | + * for a tooltip trigger with specific attributes. |
| 64 | + * @param options Options for narrowing the search. |
| 65 | + * @return a `HarnessPredicate` configured with the given options. |
| 66 | + */ |
| 67 | + static with(options: TooltipHarnessFilters = {}): HarnessPredicate<MatTooltipHarness> { |
| 68 | + return new HarnessPredicate(MatTooltipHarness, options); |
| 69 | + } |
| 70 | +} |
0 commit comments