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

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

initial commit

  • Property mode set to 100644
File size: 25.6 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 { ContentContainerComponentHarness, HarnessPredicate, TestKey, } from '@angular/cdk/testing';
10import { coerceBooleanProperty } from '@angular/cdk/coercion';
11export class _MatMenuHarnessBase extends ContentContainerComponentHarness {
12 constructor() {
13 super(...arguments);
14 this._documentRootLocator = this.documentRootLocatorFactory();
15 }
16 // TODO: potentially extend MatButtonHarness
17 /** Whether the menu is disabled. */
18 isDisabled() {
19 return __awaiter(this, void 0, void 0, function* () {
20 const disabled = (yield this.host()).getAttribute('disabled');
21 return coerceBooleanProperty(yield disabled);
22 });
23 }
24 /** Whether the menu is open. */
25 isOpen() {
26 return __awaiter(this, void 0, void 0, function* () {
27 return !!(yield this._getMenuPanel());
28 });
29 }
30 /** Gets the text of the menu's trigger element. */
31 getTriggerText() {
32 return __awaiter(this, void 0, void 0, function* () {
33 return (yield this.host()).text();
34 });
35 }
36 /** Focuses the menu. */
37 focus() {
38 return __awaiter(this, void 0, void 0, function* () {
39 return (yield this.host()).focus();
40 });
41 }
42 /** Blurs the menu. */
43 blur() {
44 return __awaiter(this, void 0, void 0, function* () {
45 return (yield this.host()).blur();
46 });
47 }
48 /** Whether the menu is focused. */
49 isFocused() {
50 return __awaiter(this, void 0, void 0, function* () {
51 return (yield this.host()).isFocused();
52 });
53 }
54 /** Opens the menu. */
55 open() {
56 return __awaiter(this, void 0, void 0, function* () {
57 if (!(yield this.isOpen())) {
58 return (yield this.host()).click();
59 }
60 });
61 }
62 /** Closes the menu. */
63 close() {
64 return __awaiter(this, void 0, void 0, function* () {
65 const panel = yield this._getMenuPanel();
66 if (panel) {
67 return panel.sendKeys(TestKey.ESCAPE);
68 }
69 });
70 }
71 /**
72 * Gets a list of `MatMenuItemHarness` representing the items in the menu.
73 * @param filters Optionally filters which menu items are included.
74 */
75 getItems(filters) {
76 return __awaiter(this, void 0, void 0, function* () {
77 const panelId = yield this._getPanelId();
78 if (panelId) {
79 return this._documentRootLocator.locatorForAll(this._itemClass.with(Object.assign(Object.assign({}, (filters || {})), { ancestor: `#${panelId}` })))();
80 }
81 return [];
82 });
83 }
84 /**
85 * Clicks an item in the menu, and optionally continues clicking items in subsequent sub-menus.
86 * @param itemFilter A filter used to represent which item in the menu should be clicked. The
87 * first matching menu item will be clicked.
88 * @param subItemFilters A list of filters representing the items to click in any subsequent
89 * sub-menus. The first item in the sub-menu matching the corresponding filter in
90 * `subItemFilters` will be clicked.
91 */
92 clickItem(itemFilter, ...subItemFilters) {
93 return __awaiter(this, void 0, void 0, function* () {
94 yield this.open();
95 const items = yield this.getItems(itemFilter);
96 if (!items.length) {
97 throw Error(`Could not find item matching ${JSON.stringify(itemFilter)}`);
98 }
99 if (!subItemFilters.length) {
100 return yield items[0].click();
101 }
102 const menu = yield items[0].getSubmenu();
103 if (!menu) {
104 throw Error(`Item matching ${JSON.stringify(itemFilter)} does not have a submenu`);
105 }
106 return menu.clickItem(...subItemFilters);
107 });
108 }
109 getRootHarnessLoader() {
110 return __awaiter(this, void 0, void 0, function* () {
111 const panelId = yield this._getPanelId();
112 return this.documentRootLocatorFactory().harnessLoaderFor(`#${panelId}`);
113 });
114 }
115 /** Gets the menu panel associated with this menu. */
116 _getMenuPanel() {
117 return __awaiter(this, void 0, void 0, function* () {
118 const panelId = yield this._getPanelId();
119 return panelId ? this._documentRootLocator.locatorForOptional(`#${panelId}`)() : null;
120 });
121 }
122 /** Gets the id of the menu panel associated with this menu. */
123 _getPanelId() {
124 return __awaiter(this, void 0, void 0, function* () {
125 const panelId = yield (yield this.host()).getAttribute('aria-controls');
126 return panelId || null;
127 });
128 }
129}
130export class _MatMenuItemHarnessBase extends ContentContainerComponentHarness {
131 /** Whether the menu is disabled. */
132 isDisabled() {
133 return __awaiter(this, void 0, void 0, function* () {
134 const disabled = (yield this.host()).getAttribute('disabled');
135 return coerceBooleanProperty(yield disabled);
136 });
137 }
138 /** Gets the text of the menu item. */
139 getText() {
140 return __awaiter(this, void 0, void 0, function* () {
141 return (yield this.host()).text();
142 });
143 }
144 /** Focuses the menu item. */
145 focus() {
146 return __awaiter(this, void 0, void 0, function* () {
147 return (yield this.host()).focus();
148 });
149 }
150 /** Blurs the menu item. */
151 blur() {
152 return __awaiter(this, void 0, void 0, function* () {
153 return (yield this.host()).blur();
154 });
155 }
156 /** Whether the menu item is focused. */
157 isFocused() {
158 return __awaiter(this, void 0, void 0, function* () {
159 return (yield this.host()).isFocused();
160 });
161 }
162 /** Clicks the menu item. */
163 click() {
164 return __awaiter(this, void 0, void 0, function* () {
165 return (yield this.host()).click();
166 });
167 }
168 /** Whether this item has a submenu. */
169 hasSubmenu() {
170 return __awaiter(this, void 0, void 0, function* () {
171 return (yield this.host()).matchesSelector(this._menuClass.hostSelector);
172 });
173 }
174 /** Gets the submenu associated with this menu item, or null if none. */
175 getSubmenu() {
176 return __awaiter(this, void 0, void 0, function* () {
177 if (yield this.hasSubmenu()) {
178 return new this._menuClass(this.locatorFactory);
179 }
180 return null;
181 });
182 }
183}
184/** Harness for interacting with a standard mat-menu in tests. */
185export class MatMenuHarness extends _MatMenuHarnessBase {
186 constructor() {
187 super(...arguments);
188 this._itemClass = MatMenuItemHarness;
189 }
190 /**
191 * Gets a `HarnessPredicate` that can be used to search for a `MatMenuHarness` that meets certain
192 * criteria.
193 * @param options Options for filtering which menu instances are considered a match.
194 * @return a `HarnessPredicate` configured with the given options.
195 */
196 static with(options = {}) {
197 return new HarnessPredicate(MatMenuHarness, options)
198 .addOption('triggerText', options.triggerText, (harness, text) => HarnessPredicate.stringMatches(harness.getTriggerText(), text));
199 }
200}
201/** The selector for the host element of a `MatMenu` instance. */
202MatMenuHarness.hostSelector = '.mat-menu-trigger';
203/** Harness for interacting with a standard mat-menu-item in tests. */
204export class MatMenuItemHarness extends _MatMenuItemHarnessBase {
205 constructor() {
206 super(...arguments);
207 this._menuClass = MatMenuHarness;
208 }
209 /**
210 * Gets a `HarnessPredicate` that can be used to search for a `MatMenuItemHarness` that meets
211 * certain criteria.
212 * @param options Options for filtering which menu item instances are considered a match.
213 * @return a `HarnessPredicate` configured with the given options.
214 */
215 static with(options = {}) {
216 return new HarnessPredicate(MatMenuItemHarness, options)
217 .addOption('text', options.text, (harness, text) => HarnessPredicate.stringMatches(harness.getText(), text))
218 .addOption('hasSubmenu', options.hasSubmenu, (harness, hasSubmenu) => __awaiter(this, void 0, void 0, function* () { return (yield harness.hasSubmenu()) === hasSubmenu; }));
219 }
220}
221/** The selector for the host element of a `MatMenuItem` instance. */
222MatMenuItemHarness.hostSelector = '.mat-menu-item';
223//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVudS1oYXJuZXNzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL21hdGVyaWFsL21lbnUvdGVzdGluZy9tZW51LWhhcm5lc3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HOztBQUVILE9BQU8sRUFJTCxnQ0FBZ0MsRUFFaEMsZ0JBQWdCLEVBRWhCLE9BQU8sR0FDUixNQUFNLHNCQUFzQixDQUFDO0FBQzlCLE9BQU8sRUFBQyxxQkFBcUIsRUFBQyxNQUFNLHVCQUF1QixDQUFDO0FBRzVELE1BQU0sT0FBZ0IsbUJBT3BCLFNBQVEsZ0NBQXdDO0lBUGxEOztRQVFVLHlCQUFvQixHQUFHLElBQUksQ0FBQywwQkFBMEIsRUFBRSxDQUFDO0lBOEduRSxDQUFDO0lBM0dDLDRDQUE0QztJQUU1QyxvQ0FBb0M7SUFDOUIsVUFBVTs7WUFDZCxNQ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