/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { ComponentHarness, HarnessPredicate, } from '@angular/cdk/testing'; export class _MatTooltipHarnessBase extends ComponentHarness { /** Shows the tooltip. */ async show() { const host = await this.host(); // We need to dispatch both `touchstart` and a hover event, because the tooltip binds // different events depending on the device. The `changedTouches` is there in case the // element has ripples. await host.dispatchEvent('touchstart', { changedTouches: [] }); await host.hover(); const panel = await this._optionalPanel(); await panel?.dispatchEvent('animationend', { animationName: this._showAnimationName }); } /** Hides the tooltip. */ async hide() { const host = await this.host(); // We need to dispatch both `touchstart` and a hover event, because // the tooltip binds different events depending on the device. await host.dispatchEvent('touchend'); await host.mouseAway(); const panel = await this._optionalPanel(); await panel?.dispatchEvent('animationend', { animationName: this._hideAnimationName }); } /** Gets whether the tooltip is open. */ async isOpen() { const panel = await this._optionalPanel(); return !!panel && !(await panel.hasClass(this._hiddenClass)); } /** Gets whether the tooltip is disabled */ async isDisabled() { const host = await this.host(); return host.hasClass(this._disabledClass); } /** Gets a promise for the tooltip panel's text. */ async getTooltipText() { const panel = await this._optionalPanel(); return panel ? panel.text() : ''; } } /** Harness for interacting with a standard mat-tooltip in tests. */ export class MatTooltipHarness extends _MatTooltipHarnessBase { constructor() { super(...arguments); this._optionalPanel = this.documentRootLocatorFactory().locatorForOptional('.mat-mdc-tooltip'); this._hiddenClass = 'mat-mdc-tooltip-hide'; this._disabledClass = 'mat-mdc-tooltip-disabled'; this._showAnimationName = 'mat-mdc-tooltip-show'; this._hideAnimationName = 'mat-mdc-tooltip-hide'; } static { this.hostSelector = '.mat-mdc-tooltip-trigger'; } /** * Gets a `HarnessPredicate` that can be used to search for a tooltip trigger with specific * attributes. * @param options Options for narrowing the search. * @return a `HarnessPredicate` configured with the given options. */ static with(options = {}) { return new HarnessPredicate(this, options); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9vbHRpcC1o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