source: trip-planner-front/node_modules/@angular/material/esm2015/tooltip/testing/tooltip-harness.js@ 6c1585f

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

initial commit

  • Property mode set to 100644
File size: 8.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 { ComponentHarness, HarnessPredicate, } from '@angular/cdk/testing';
10export class _MatTooltipHarnessBase extends ComponentHarness {
11 /** Shows the tooltip. */
12 show() {
13 var _a;
14 return __awaiter(this, void 0, void 0, function* () {
15 const host = yield this.host();
16 // We need to dispatch both `touchstart` and a hover event, because the tooltip binds
17 // different events depending on the device. The `changedTouches` is there in case the
18 // element has ripples.
19 // @breaking-change 12.0.0 Remove null assertion from `dispatchEvent`.
20 yield ((_a = host.dispatchEvent) === null || _a === void 0 ? void 0 : _a.call(host, 'touchstart', { changedTouches: [] }));
21 yield host.hover();
22 });
23 }
24 /** Hides the tooltip. */
25 hide() {
26 var _a;
27 return __awaiter(this, void 0, void 0, function* () {
28 const host = yield this.host();
29 // We need to dispatch both `touchstart` and a hover event, because
30 // the tooltip binds different events depending on the device.
31 // @breaking-change 12.0.0 Remove null assertion from `dispatchEvent`.
32 yield ((_a = host.dispatchEvent) === null || _a === void 0 ? void 0 : _a.call(host, 'touchend'));
33 yield host.mouseAway();
34 yield this.forceStabilize(); // Needed in order to flush the `hide` animation.
35 });
36 }
37 /** Gets whether the tooltip is open. */
38 isOpen() {
39 return __awaiter(this, void 0, void 0, function* () {
40 return !!(yield this._optionalPanel());
41 });
42 }
43 /** Gets a promise for the tooltip panel's text. */
44 getTooltipText() {
45 return __awaiter(this, void 0, void 0, function* () {
46 const panel = yield this._optionalPanel();
47 return panel ? panel.text() : '';
48 });
49 }
50}
51/** Harness for interacting with a standard mat-tooltip in tests. */
52export class MatTooltipHarness extends _MatTooltipHarnessBase {
53 constructor() {
54 super(...arguments);
55 this._optionalPanel = this.documentRootLocatorFactory().locatorForOptional('.mat-tooltip');
56 }
57 /**
58 * Gets a `HarnessPredicate` that can be used to search
59 * for a tooltip trigger with specific attributes.
60 * @param options Options for narrowing the search.
61 * @return a `HarnessPredicate` configured with the given options.
62 */
63 static with(options = {}) {
64 return new HarnessPredicate(MatTooltipHarness, options);
65 }
66}
67MatTooltipHarness.hostSelector = '.mat-tooltip-trigger';
68//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9vbHRpcC1oYXJuZXNzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL21hdGVyaWFsL3Rvb2x0aXAvdGVzdGluZy90b29sdGlwLWhhcm5lc3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HOztBQUVILE9BQU8sRUFFTCxnQkFBZ0IsRUFDaEIsZ0JBQWdCLEdBRWpCLE1BQU0sc0JBQXNCLENBQUM7QUFHOUIsTUFBTSxPQUFnQixzQkFBdUIsU0FBUSxnQkFBZ0I7SUFHbkUseUJBQXlCO0lBQ25CLElBQUk7OztZQUNSLE1BQU0sSUFBSSxHQUFHLE1BQU0sSUFBSSxDQUFDLElBQUksRUFBRSxDQUFDO1lBRS9CLHFGQUFxRjtZQUNyRixzRkFBc0Y7WUFDdEYsdUJBQXVCO1lBQ3ZCLHNFQUFzRTtZQUN0RSxNQUFNLENBQUEsTUFBQSxJQUFJLENBQUMsYUFBYSwrQ0FBbEIsSUFBSSxFQUFpQixZQUFZLEVBQUUsRUFBQyxjQUFjLEVBQUUsRUFBRSxFQUFDLENBQUMsQ0FBQSxDQUFDO1lBQy9ELE1BQU0sSUFBSSxDQUFDLEtBQUssRUFBRSxDQUFDOztLQUNwQjtJQUVELHlCQUF5QjtJQUNuQixJQUFJOzs7WUFDUixNQUFNLElBQUksR0FBR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