source: trip-planner-front/node_modules/@angular/material/fesm2015/tooltip/testing.js@ ceaed42

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

initial commit

  • Property mode set to 100644
File size: 3.5 KB
Line 
1import { __awaiter } from 'tslib';
2import { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
3
4/**
5 * @license
6 * Copyright Google LLC All Rights Reserved.
7 *
8 * Use of this source code is governed by an MIT-style license that can be
9 * found in the LICENSE file at https://angular.io/license
10 */
11class _MatTooltipHarnessBase extends ComponentHarness {
12 /** Shows the tooltip. */
13 show() {
14 var _a;
15 return __awaiter(this, void 0, void 0, function* () {
16 const host = yield this.host();
17 // We need to dispatch both `touchstart` and a hover event, because the tooltip binds
18 // different events depending on the device. The `changedTouches` is there in case the
19 // element has ripples.
20 // @breaking-change 12.0.0 Remove null assertion from `dispatchEvent`.
21 yield ((_a = host.dispatchEvent) === null || _a === void 0 ? void 0 : _a.call(host, 'touchstart', { changedTouches: [] }));
22 yield host.hover();
23 });
24 }
25 /** Hides the tooltip. */
26 hide() {
27 var _a;
28 return __awaiter(this, void 0, void 0, function* () {
29 const host = yield this.host();
30 // We need to dispatch both `touchstart` and a hover event, because
31 // the tooltip binds different events depending on the device.
32 // @breaking-change 12.0.0 Remove null assertion from `dispatchEvent`.
33 yield ((_a = host.dispatchEvent) === null || _a === void 0 ? void 0 : _a.call(host, 'touchend'));
34 yield host.mouseAway();
35 yield this.forceStabilize(); // Needed in order to flush the `hide` animation.
36 });
37 }
38 /** Gets whether the tooltip is open. */
39 isOpen() {
40 return __awaiter(this, void 0, void 0, function* () {
41 return !!(yield this._optionalPanel());
42 });
43 }
44 /** Gets a promise for the tooltip panel's text. */
45 getTooltipText() {
46 return __awaiter(this, void 0, void 0, function* () {
47 const panel = yield this._optionalPanel();
48 return panel ? panel.text() : '';
49 });
50 }
51}
52/** Harness for interacting with a standard mat-tooltip in tests. */
53class MatTooltipHarness extends _MatTooltipHarnessBase {
54 constructor() {
55 super(...arguments);
56 this._optionalPanel = this.documentRootLocatorFactory().locatorForOptional('.mat-tooltip');
57 }
58 /**
59 * Gets a `HarnessPredicate` that can be used to search
60 * for a tooltip trigger with specific attributes.
61 * @param options Options for narrowing the search.
62 * @return a `HarnessPredicate` configured with the given options.
63 */
64 static with(options = {}) {
65 return new HarnessPredicate(MatTooltipHarness, options);
66 }
67}
68MatTooltipHarness.hostSelector = '.mat-tooltip-trigger';
69
70/**
71 * @license
72 * Copyright Google LLC All Rights Reserved.
73 *
74 * Use of this source code is governed by an MIT-style license that can be
75 * found in the LICENSE file at https://angular.io/license
76 */
77
78/**
79 * @license
80 * Copyright Google LLC All Rights Reserved.
81 *
82 * Use of this source code is governed by an MIT-style license that can be
83 * found in the LICENSE file at https://angular.io/license
84 */
85
86/**
87 * @license
88 * Copyright Google LLC All Rights Reserved.
89 *
90 * Use of this source code is governed by an MIT-style license that can be
91 * found in the LICENSE file at https://angular.io/license
92 */
93
94export { MatTooltipHarness, _MatTooltipHarnessBase };
95//# sourceMappingURL=testing.js.map
Note: See TracBrowser for help on using the repository browser.