source: trip-planner-front/node_modules/@angular/material/bundles/material-list-testing.umd.js@ fa375fe

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

initial commit

  • Property mode set to 100644
File size: 52.2 KB
Line 
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/testing'), require('@angular/material/divider/testing')) :
3 typeof define === 'function' && define.amd ? define('@angular/material/list/testing', ['exports', '@angular/cdk/testing', '@angular/material/divider/testing'], factory) :
4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ng = global.ng || {}, global.ng.material = global.ng.material || {}, global.ng.material.list = global.ng.material.list || {}, global.ng.material.list.testing = {}), global.ng.cdk.testing, global.ng.material.divider.testing));
5}(this, (function (exports, testing, testing$1) { 'use strict';
6
7 /*! *****************************************************************************
8 Copyright (c) Microsoft Corporation.
9
10 Permission to use, copy, modify, and/or distribute this software for any
11 purpose with or without fee is hereby granted.
12
13 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 PERFORMANCE OF THIS SOFTWARE.
20 ***************************************************************************** */
21 /* global Reflect, Promise */
22 var extendStatics = function (d, b) {
23 extendStatics = Object.setPrototypeOf ||
24 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25 function (d, b) { for (var p in b)
26 if (Object.prototype.hasOwnProperty.call(b, p))
27 d[p] = b[p]; };
28 return extendStatics(d, b);
29 };
30 function __extends(d, b) {
31 if (typeof b !== "function" && b !== null)
32 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
33 extendStatics(d, b);
34 function __() { this.constructor = d; }
35 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
36 }
37 var __assign = function () {
38 __assign = Object.assign || function __assign(t) {
39 for (var s, i = 1, n = arguments.length; i < n; i++) {
40 s = arguments[i];
41 for (var p in s)
42 if (Object.prototype.hasOwnProperty.call(s, p))
43 t[p] = s[p];
44 }
45 return t;
46 };
47 return __assign.apply(this, arguments);
48 };
49 function __rest(s, e) {
50 var t = {};
51 for (var p in s)
52 if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
53 t[p] = s[p];
54 if (s != null && typeof Object.getOwnPropertySymbols === "function")
55 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
56 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
57 t[p[i]] = s[p[i]];
58 }
59 return t;
60 }
61 function __decorate(decorators, target, key, desc) {
62 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
63 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
64 r = Reflect.decorate(decorators, target, key, desc);
65 else
66 for (var i = decorators.length - 1; i >= 0; i--)
67 if (d = decorators[i])
68 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
69 return c > 3 && r && Object.defineProperty(target, key, r), r;
70 }
71 function __param(paramIndex, decorator) {
72 return function (target, key) { decorator(target, key, paramIndex); };
73 }
74 function __metadata(metadataKey, metadataValue) {
75 if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
76 return Reflect.metadata(metadataKey, metadataValue);
77 }
78 function __awaiter(thisArg, _arguments, P, generator) {
79 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
80 return new (P || (P = Promise))(function (resolve, reject) {
81 function fulfilled(value) { try {
82 step(generator.next(value));
83 }
84 catch (e) {
85 reject(e);
86 } }
87 function rejected(value) { try {
88 step(generator["throw"](value));
89 }
90 catch (e) {
91 reject(e);
92 } }
93 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
94 step((generator = generator.apply(thisArg, _arguments || [])).next());
95 });
96 }
97 function __generator(thisArg, body) {
98 var _ = { label: 0, sent: function () { if (t[0] & 1)
99 throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
100 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
101 function verb(n) { return function (v) { return step([n, v]); }; }
102 function step(op) {
103 if (f)
104 throw new TypeError("Generator is already executing.");
105 while (_)
106 try {
107 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
108 return t;
109 if (y = 0, t)
110 op = [op[0] & 2, t.value];
111 switch (op[0]) {
112 case 0:
113 case 1:
114 t = op;
115 break;
116 case 4:
117 _.label++;
118 return { value: op[1], done: false };
119 case 5:
120 _.label++;
121 y = op[1];
122 op = [0];
123 continue;
124 case 7:
125 op = _.ops.pop();
126 _.trys.pop();
127 continue;
128 default:
129 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
130 _ = 0;
131 continue;
132 }
133 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
134 _.label = op[1];
135 break;
136 }
137 if (op[0] === 6 && _.label < t[1]) {
138 _.label = t[1];
139 t = op;
140 break;
141 }
142 if (t && _.label < t[2]) {
143 _.label = t[2];
144 _.ops.push(op);
145 break;
146 }
147 if (t[2])
148 _.ops.pop();
149 _.trys.pop();
150 continue;
151 }
152 op = body.call(thisArg, _);
153 }
154 catch (e) {
155 op = [6, e];
156 y = 0;
157 }
158 finally {
159 f = t = 0;
160 }
161 if (op[0] & 5)
162 throw op[1];
163 return { value: op[0] ? op[1] : void 0, done: true };
164 }
165 }
166 var __createBinding = Object.create ? (function (o, m, k, k2) {
167 if (k2 === undefined)
168 k2 = k;
169 Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
170 }) : (function (o, m, k, k2) {
171 if (k2 === undefined)
172 k2 = k;
173 o[k2] = m[k];
174 });
175 function __exportStar(m, o) {
176 for (var p in m)
177 if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
178 __createBinding(o, m, p);
179 }
180 function __values(o) {
181 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
182 if (m)
183 return m.call(o);
184 if (o && typeof o.length === "number")
185 return {
186 next: function () {
187 if (o && i >= o.length)
188 o = void 0;
189 return { value: o && o[i++], done: !o };
190 }
191 };
192 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
193 }
194 function __read(o, n) {
195 var m = typeof Symbol === "function" && o[Symbol.iterator];
196 if (!m)
197 return o;
198 var i = m.call(o), r, ar = [], e;
199 try {
200 while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
201 ar.push(r.value);
202 }
203 catch (error) {
204 e = { error: error };
205 }
206 finally {
207 try {
208 if (r && !r.done && (m = i["return"]))
209 m.call(i);
210 }
211 finally {
212 if (e)
213 throw e.error;
214 }
215 }
216 return ar;
217 }
218 /** @deprecated */
219 function __spread() {
220 for (var ar = [], i = 0; i < arguments.length; i++)
221 ar = ar.concat(__read(arguments[i]));
222 return ar;
223 }
224 /** @deprecated */
225 function __spreadArrays() {
226 for (var s = 0, i = 0, il = arguments.length; i < il; i++)
227 s += arguments[i].length;
228 for (var r = Array(s), k = 0, i = 0; i < il; i++)
229 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
230 r[k] = a[j];
231 return r;
232 }
233 function __spreadArray(to, from, pack) {
234 if (pack || arguments.length === 2)
235 for (var i = 0, l = from.length, ar; i < l; i++) {
236 if (ar || !(i in from)) {
237 if (!ar)
238 ar = Array.prototype.slice.call(from, 0, i);
239 ar[i] = from[i];
240 }
241 }
242 return to.concat(ar || from);
243 }
244 function __await(v) {
245 return this instanceof __await ? (this.v = v, this) : new __await(v);
246 }
247 function __asyncGenerator(thisArg, _arguments, generator) {
248 if (!Symbol.asyncIterator)
249 throw new TypeError("Symbol.asyncIterator is not defined.");
250 var g = generator.apply(thisArg, _arguments || []), i, q = [];
251 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
252 function verb(n) { if (g[n])
253 i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
254 function resume(n, v) { try {
255 step(g[n](v));
256 }
257 catch (e) {
258 settle(q[0][3], e);
259 } }
260 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
261 function fulfill(value) { resume("next", value); }
262 function reject(value) { resume("throw", value); }
263 function settle(f, v) { if (f(v), q.shift(), q.length)
264 resume(q[0][0], q[0][1]); }
265 }
266 function __asyncDelegator(o) {
267 var i, p;
268 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
269 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
270 }
271 function __asyncValues(o) {
272 if (!Symbol.asyncIterator)
273 throw new TypeError("Symbol.asyncIterator is not defined.");
274 var m = o[Symbol.asyncIterator], i;
275 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
276 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
277 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
278 }
279 function __makeTemplateObject(cooked, raw) {
280 if (Object.defineProperty) {
281 Object.defineProperty(cooked, "raw", { value: raw });
282 }
283 else {
284 cooked.raw = raw;
285 }
286 return cooked;
287 }
288 ;
289 var __setModuleDefault = Object.create ? (function (o, v) {
290 Object.defineProperty(o, "default", { enumerable: true, value: v });
291 }) : function (o, v) {
292 o["default"] = v;
293 };
294 function __importStar(mod) {
295 if (mod && mod.__esModule)
296 return mod;
297 var result = {};
298 if (mod != null)
299 for (var k in mod)
300 if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
301 __createBinding(result, mod, k);
302 __setModuleDefault(result, mod);
303 return result;
304 }
305 function __importDefault(mod) {
306 return (mod && mod.__esModule) ? mod : { default: mod };
307 }
308 function __classPrivateFieldGet(receiver, state, kind, f) {
309 if (kind === "a" && !f)
310 throw new TypeError("Private accessor was defined without a getter");
311 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
312 throw new TypeError("Cannot read private member from an object whose class did not declare it");
313 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
314 }
315 function __classPrivateFieldSet(receiver, state, value, kind, f) {
316 if (kind === "m")
317 throw new TypeError("Private method is not writable");
318 if (kind === "a" && !f)
319 throw new TypeError("Private accessor was defined without a setter");
320 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
321 throw new TypeError("Cannot write private member to an object whose class did not declare it");
322 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
323 }
324
325 var iconSelector = '.mat-list-icon';
326 var avatarSelector = '.mat-list-avatar';
327 /**
328 * Gets a `HarnessPredicate` that applies the given `BaseListItemHarnessFilters` to the given
329 * list item harness.
330 * @template H The type of list item harness to create a predicate for.
331 * @param harnessType A constructor for a list item harness.
332 * @param options An instance of `BaseListItemHarnessFilters` to apply.
333 * @return A `HarnessPredicate` for the given harness type with the given options applied.
334 */
335 function getListItemPredicate(harnessType, options) {
336 return new testing.HarnessPredicate(harnessType, options)
337 .addOption('text', options.text, function (harness, text) { return testing.HarnessPredicate.stringMatches(harness.getText(), text); });
338 }
339 /** Harness for interacting with a list subheader. */
340 var MatSubheaderHarness = /** @class */ (function (_super) {
341 __extends(MatSubheaderHarness, _super);
342 function MatSubheaderHarness() {
343 return _super !== null && _super.apply(this, arguments) || this;
344 }
345 MatSubheaderHarness.with = function (options) {
346 if (options === void 0) { options = {}; }
347 return new testing.HarnessPredicate(MatSubheaderHarness, options)
348 .addOption('text', options.text, function (harness, text) { return testing.HarnessPredicate.stringMatches(harness.getText(), text); });
349 };
350 /** Gets the full text content of the list item (including text from any font icons). */
351 MatSubheaderHarness.prototype.getText = function () {
352 return __awaiter(this, void 0, void 0, function () {
353 return __generator(this, function (_a) {
354 switch (_a.label) {
355 case 0: return [4 /*yield*/, this.host()];
356 case 1: return [2 /*return*/, (_a.sent()).text()];
357 }
358 });
359 });
360 };
361 return MatSubheaderHarness;
362 }(testing.ComponentHarness));
363 MatSubheaderHarness.hostSelector = '.mat-subheader';
364 /**
365 * Shared behavior among the harnesses for the various `MatListItem` flavors.
366 * @docs-private
367 */
368 var MatListItemHarnessBase = /** @class */ (function (_super) {
369 __extends(MatListItemHarnessBase, _super);
370 function MatListItemHarnessBase() {
371 var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
372 _this._lines = _this.locatorForAll('.mat-line');
373 _this._avatar = _this.locatorForOptional(avatarSelector);
374 _this._icon = _this.locatorForOptional(iconSelector);
375 return _this;
376 }
377 /** Gets the full text content of the list item. */
378 MatListItemHarnessBase.prototype.getText = function () {
379 return __awaiter(this, void 0, void 0, function () {
380 return __generator(this, function (_a) {
381 switch (_a.label) {
382 case 0: return [4 /*yield*/, this.host()];
383 case 1: return [2 /*return*/, (_a.sent()).text({ exclude: iconSelector + ", " + avatarSelector })];
384 }
385 });
386 });
387 };
388 /** Gets the lines of text (`mat-line` elements) in this nav list item. */
389 MatListItemHarnessBase.prototype.getLinesText = function () {
390 return __awaiter(this, void 0, void 0, function () {
391 var lines;
392 return __generator(this, function (_a) {
393 switch (_a.label) {
394 case 0: return [4 /*yield*/, this._lines()];
395 case 1:
396 lines = _a.sent();
397 return [2 /*return*/, testing.parallel(function () { return lines.map(function (l) { return l.text(); }); })];
398 }
399 });
400 });
401 };
402 /** Whether this list item has an avatar. */
403 MatListItemHarnessBase.prototype.hasAvatar = function () {
404 return __awaiter(this, void 0, void 0, function () {
405 return __generator(this, function (_a) {
406 switch (_a.label) {
407 case 0: return [4 /*yield*/, this._avatar()];
408 case 1: return [2 /*return*/, !!(_a.sent())];
409 }
410 });
411 });
412 };
413 /** Whether this list item has an icon. */
414 MatListItemHarnessBase.prototype.hasIcon = function () {
415 return __awaiter(this, void 0, void 0, function () {
416 return __generator(this, function (_a) {
417 switch (_a.label) {
418 case 0: return [4 /*yield*/, this._icon()];
419 case 1: return [2 /*return*/, !!(_a.sent())];
420 }
421 });
422 });
423 };
424 /**
425 * Gets a `HarnessLoader` used to get harnesses within the list item's content.
426 * @deprecated Use `getChildLoader(MatListItemSection.CONTENT)` or `getHarness` instead.
427 * @breaking-change 12.0.0
428 */
429 MatListItemHarnessBase.prototype.getHarnessLoaderForContent = function () {
430 return __awaiter(this, void 0, void 0, function () {
431 return __generator(this, function (_a) {
432 return [2 /*return*/, this.getChildLoader(".mat-list-item-content" /* CONTENT */)];
433 });
434 });
435 };
436 return MatListItemHarnessBase;
437 }(testing.ContentContainerComponentHarness));
438
439 /**
440 * Shared behavior among the harnesses for the various `MatList` flavors.
441 * @template T A constructor type for a list item harness type used by this list harness.
442 * @template C The list item harness type that `T` constructs.
443 * @template F The filter type used filter list item harness of type `C`.
444 * @docs-private
445 */
446 var MatListHarnessBase = /** @class */ (function (_super) {
447 __extends(MatListHarnessBase, _super);
448 function MatListHarnessBase() {
449 return _super !== null && _super.apply(this, arguments) || this;
450 }
451 /**
452 * Gets a list of harnesses representing the items in this list.
453 * @param filters Optional filters used to narrow which harnesses are included
454 * @return The list of items matching the given filters.
455 */
456 MatListHarnessBase.prototype.getItems = function (filters) {
457 return __awaiter(this, void 0, void 0, function () {
458 return __generator(this, function (_a) {
459 return [2 /*return*/, this.locatorForAll(this._itemHarness.with(filters))()];
460 });
461 });
462 };
463 /**
464 * Gets a list of `ListSection` representing the list items grouped by subheaders. If the list has
465 * no subheaders it is represented as a single `ListSection` with an undefined `heading` property.
466 * @param filters Optional filters used to narrow which list item harnesses are included
467 * @return The list of items matching the given filters, grouped into sections by subheader.
468 */
469 MatListHarnessBase.prototype.getItemsGroupedBySubheader = function (filters) {
470 return __awaiter(this, void 0, void 0, function () {
471 var listSections, currentSection, itemsAndSubheaders, itemsAndSubheaders_1, itemsAndSubheaders_1_1, itemOrSubheader;
472 var e_1, _a;
473 var _this = this;
474 return __generator(this, function (_b) {
475 switch (_b.label) {
476 case 0:
477 listSections = [];
478 currentSection = { items: [] };
479 return [4 /*yield*/, this.getItemsWithSubheadersAndDividers({ item: filters, divider: false })];
480 case 1:
481 itemsAndSubheaders = _b.sent();
482 try {
483 for (itemsAndSubheaders_1 = __values(itemsAndSubheaders), itemsAndSubheaders_1_1 = itemsAndSubheaders_1.next(); !itemsAndSubheaders_1_1.done; itemsAndSubheaders_1_1 = itemsAndSubheaders_1.next()) {
484 itemOrSubheader = itemsAndSubheaders_1_1.value;
485 if (itemOrSubheader instanceof MatSubheaderHarness) {
486 if (currentSection.heading !== undefined || currentSection.items.length) {
487 listSections.push(currentSection);
488 }
489 currentSection = { heading: itemOrSubheader.getText(), items: [] };
490 }
491 else {
492 currentSection.items.push(itemOrSubheader);
493 }
494 }
495 }
496 catch (e_1_1) { e_1 = { error: e_1_1 }; }
497 finally {
498 try {
499 if (itemsAndSubheaders_1_1 && !itemsAndSubheaders_1_1.done && (_a = itemsAndSubheaders_1.return)) _a.call(itemsAndSubheaders_1);
500 }
501 finally { if (e_1) throw e_1.error; }
502 }
503 if (currentSection.heading !== undefined || currentSection.items.length ||
504 !listSections.length) {
505 listSections.push(currentSection);
506 }
507 // Concurrently wait for all sections to resolve their heading if present.
508 return [2 /*return*/, testing.parallel(function () { return listSections.map(function (s) { return __awaiter(_this, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
509 switch (_b.label) {
510 case 0:
511 _a = { items: s.items };
512 return [4 /*yield*/, s.heading];
513 case 1: return [2 /*return*/, (_a.heading = _b.sent(), _a)];
514 }
515 }); }); }); })];
516 }
517 });
518 });
519 };
520 /**
521 * Gets a list of sub-lists representing the list items grouped by dividers. If the list has no
522 * dividers it is represented as a list with a single sub-list.
523 * @param filters Optional filters used to narrow which list item harnesses are included
524 * @return The list of items matching the given filters, grouped into sub-lists by divider.
525 */
526 MatListHarnessBase.prototype.getItemsGroupedByDividers = function (filters) {
527 return __awaiter(this, void 0, void 0, function () {
528 var listSections, itemsAndDividers, itemsAndDividers_1, itemsAndDividers_1_1, itemOrDivider;
529 var e_2, _a;
530 return __generator(this, function (_b) {
531 switch (_b.label) {
532 case 0:
533 listSections = [[]];
534 return [4 /*yield*/, this.getItemsWithSubheadersAndDividers({ item: filters, subheader: false })];
535 case 1:
536 itemsAndDividers = _b.sent();
537 try {
538 for (itemsAndDividers_1 = __values(itemsAndDividers), itemsAndDividers_1_1 = itemsAndDividers_1.next(); !itemsAndDividers_1_1.done; itemsAndDividers_1_1 = itemsAndDividers_1.next()) {
539 itemOrDivider = itemsAndDividers_1_1.value;
540 if (itemOrDivider instanceof testing$1.MatDividerHarness) {
541 listSections.push([]);
542 }
543 else {
544 listSections[listSections.length - 1].push(itemOrDivider);
545 }
546 }
547 }
548 catch (e_2_1) { e_2 = { error: e_2_1 }; }
549 finally {
550 try {
551 if (itemsAndDividers_1_1 && !itemsAndDividers_1_1.done && (_a = itemsAndDividers_1.return)) _a.call(itemsAndDividers_1);
552 }
553 finally { if (e_2) throw e_2.error; }
554 }
555 return [2 /*return*/, listSections];
556 }
557 });
558 });
559 };
560 MatListHarnessBase.prototype.getItemsWithSubheadersAndDividers = function (filters) {
561 if (filters === void 0) { filters = {}; }
562 return __awaiter(this, void 0, void 0, function () {
563 var query;
564 return __generator(this, function (_a) {
565 query = [];
566 if (filters.item !== false) {
567 query.push(this._itemHarness.with(filters.item || {}));
568 }
569 if (filters.subheader !== false) {
570 query.push(MatSubheaderHarness.with(filters.subheader));
571 }
572 if (filters.divider !== false) {
573 query.push(testing$1.MatDividerHarness.with(filters.divider));
574 }
575 return [2 /*return*/, this.locatorForAll.apply(this, __spreadArray([], __read(query)))()];
576 });
577 });
578 };
579 return MatListHarnessBase;
580 }(testing.ComponentHarness));
581
582 /** Harness for interacting with a standard mat-action-list in tests. */
583 var MatActionListHarness = /** @class */ (function (_super) {
584 __extends(MatActionListHarness, _super);
585 function MatActionListHarness() {
586 var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
587 _this._itemHarness = MatActionListItemHarness;
588 return _this;
589 }
590 /**
591 * Gets a `HarnessPredicate` that can be used to search for a `MatActionListHarness` that meets
592 * certain criteria.
593 * @param options Options for filtering which action list instances are considered a match.
594 * @return a `HarnessPredicate` configured with the given options.
595 */
596 MatActionListHarness.with = function (options) {
597 if (options === void 0) { options = {}; }
598 return new testing.HarnessPredicate(MatActionListHarness, options);
599 };
600 return MatActionListHarness;
601 }(MatListHarnessBase));
602 /** The selector for the host element of a `MatActionList` instance. */
603 MatActionListHarness.hostSelector = 'mat-action-list.mat-list';
604 /** Harness for interacting with an action list item. */
605 var MatActionListItemHarness = /** @class */ (function (_super) {
606 __extends(MatActionListItemHarness, _super);
607 function MatActionListItemHarness() {
608 return _super !== null && _super.apply(this, arguments) || this;
609 }
610 /**
611 * Gets a `HarnessPredicate` that can be used to search for a `MatActionListItemHarness` that
612 * meets certain criteria.
613 * @param options Options for filtering which action list item instances are considered a match.
614 * @return a `HarnessPredicate` configured with the given options.
615 */
616 MatActionListItemHarness.with = function (options) {
617 if (options === void 0) { options = {}; }
618 return getListItemPredicate(MatActionListItemHarness, options);
619 };
620 /** Clicks on the action list item. */
621 MatActionListItemHarness.prototype.click = function () {
622 return __awaiter(this, void 0, void 0, function () {
623 return __generator(this, function (_a) {
624 switch (_a.label) {
625 case 0: return [4 /*yield*/, this.host()];
626 case 1: return [2 /*return*/, (_a.sent()).click()];
627 }
628 });
629 });
630 };
631 /** Focuses the action list item. */
632 MatActionListItemHarness.prototype.focus = function () {
633 return __awaiter(this, void 0, void 0, function () {
634 return __generator(this, function (_a) {
635 switch (_a.label) {
636 case 0: return [4 /*yield*/, this.host()];
637 case 1: return [2 /*return*/, (_a.sent()).focus()];
638 }
639 });
640 });
641 };
642 /** Blurs the action list item. */
643 MatActionListItemHarness.prototype.blur = function () {
644 return __awaiter(this, void 0, void 0, function () {
645 return __generator(this, function (_a) {
646 switch (_a.label) {
647 case 0: return [4 /*yield*/, this.host()];
648 case 1: return [2 /*return*/, (_a.sent()).blur()];
649 }
650 });
651 });
652 };
653 /** Whether the action list item is focused. */
654 MatActionListItemHarness.prototype.isFocused = function () {
655 return __awaiter(this, void 0, void 0, function () {
656 return __generator(this, function (_a) {
657 switch (_a.label) {
658 case 0: return [4 /*yield*/, this.host()];
659 case 1: return [2 /*return*/, (_a.sent()).isFocused()];
660 }
661 });
662 });
663 };
664 return MatActionListItemHarness;
665 }(MatListItemHarnessBase));
666 /** The selector for the host element of a `MatListItem` instance. */
667 MatActionListItemHarness.hostSelector = MatActionListHarness.hostSelector + " .mat-list-item";
668
669 /** Harness for interacting with a standard mat-list in tests. */
670 var MatListHarness = /** @class */ (function (_super) {
671 __extends(MatListHarness, _super);
672 function MatListHarness() {
673 var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
674 _this._itemHarness = MatListItemHarness;
675 return _this;
676 }
677 /**
678 * Gets a `HarnessPredicate` that can be used to search for a `MatListHarness` that meets certain
679 * criteria.
680 * @param options Options for filtering which list instances are considered a match.
681 * @return a `HarnessPredicate` configured with the given options.
682 */
683 MatListHarness.with = function (options) {
684 if (options === void 0) { options = {}; }
685 return new testing.HarnessPredicate(MatListHarness, options);
686 };
687 return MatListHarness;
688 }(MatListHarnessBase));
689 /** The selector for the host element of a `MatList` instance. */
690 MatListHarness.hostSelector = '.mat-list:not(mat-action-list)';
691 /** Harness for interacting with a list item. */
692 var MatListItemHarness = /** @class */ (function (_super) {
693 __extends(MatListItemHarness, _super);
694 function MatListItemHarness() {
695 return _super !== null && _super.apply(this, arguments) || this;
696 }
697 /**
698 * Gets a `HarnessPredicate` that can be used to search for a `MatListItemHarness` that meets
699 * certain criteria.
700 * @param options Options for filtering which list item instances are considered a match.
701 * @return a `HarnessPredicate` configured with the given options.
702 */
703 MatListItemHarness.with = function (options) {
704 if (options === void 0) { options = {}; }
705 return getListItemPredicate(MatListItemHarness, options);
706 };
707 return MatListItemHarness;
708 }(MatListItemHarnessBase));
709 /** The selector for the host element of a `MatListItem` instance. */
710 MatListItemHarness.hostSelector = MatListHarness.hostSelector + " .mat-list-item";
711
712 /** Harness for interacting with a standard mat-nav-list in tests. */
713 var MatNavListHarness = /** @class */ (function (_super) {
714 __extends(MatNavListHarness, _super);
715 function MatNavListHarness() {
716 var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
717 _this._itemHarness = MatNavListItemHarness;
718 return _this;
719 }
720 /**
721 * Gets a `HarnessPredicate` that can be used to search for a `MatNavListHarness` that meets
722 * certain criteria.
723 * @param options Options for filtering which nav list instances are considered a match.
724 * @return a `HarnessPredicate` configured with the given options.
725 */
726 MatNavListHarness.with = function (options) {
727 if (options === void 0) { options = {}; }
728 return new testing.HarnessPredicate(MatNavListHarness, options);
729 };
730 return MatNavListHarness;
731 }(MatListHarnessBase));
732 /** The selector for the host element of a `MatNavList` instance. */
733 MatNavListHarness.hostSelector = '.mat-nav-list';
734 /** Harness for interacting with a nav list item. */
735 var MatNavListItemHarness = /** @class */ (function (_super) {
736 __extends(MatNavListItemHarness, _super);
737 function MatNavListItemHarness() {
738 return _super !== null && _super.apply(this, arguments) || this;
739 }
740 /**
741 * Gets a `HarnessPredicate` that can be used to search for a `MatNavListItemHarness` that
742 * meets certain criteria.
743 * @param options Options for filtering which nav list item instances are considered a match.
744 * @return a `HarnessPredicate` configured with the given options.
745 */
746 MatNavListItemHarness.with = function (options) {
747 var _this = this;
748 if (options === void 0) { options = {}; }
749 return getListItemPredicate(MatNavListItemHarness, options)
750 .addOption('href', options.href, function (harness, href) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
751 return [2 /*return*/, testing.HarnessPredicate.stringMatches(harness.getHref(), href)];
752 }); }); });
753 };
754 /** Gets the href for this nav list item. */
755 MatNavListItemHarness.prototype.getHref = function () {
756 return __awaiter(this, void 0, void 0, function () {
757 return __generator(this, function (_a) {
758 switch (_a.label) {
759 case 0: return [4 /*yield*/, this.host()];
760 case 1: return [2 /*return*/, (_a.sent()).getAttribute('href')];
761 }
762 });
763 });
764 };
765 /** Clicks on the nav list item. */
766 MatNavListItemHarness.prototype.click = function () {
767 return __awaiter(this, void 0, void 0, function () {
768 return __generator(this, function (_a) {
769 switch (_a.label) {
770 case 0: return [4 /*yield*/, this.host()];
771 case 1: return [2 /*return*/, (_a.sent()).click()];
772 }
773 });
774 });
775 };
776 /** Focuses the nav list item. */
777 MatNavListItemHarness.prototype.focus = function () {
778 return __awaiter(this, void 0, void 0, function () {
779 return __generator(this, function (_a) {
780 switch (_a.label) {
781 case 0: return [4 /*yield*/, this.host()];
782 case 1: return [2 /*return*/, (_a.sent()).focus()];
783 }
784 });
785 });
786 };
787 /** Blurs the nav list item. */
788 MatNavListItemHarness.prototype.blur = function () {
789 return __awaiter(this, void 0, void 0, function () {
790 return __generator(this, function (_a) {
791 switch (_a.label) {
792 case 0: return [4 /*yield*/, this.host()];
793 case 1: return [2 /*return*/, (_a.sent()).blur()];
794 }
795 });
796 });
797 };
798 /** Whether the nav list item is focused. */
799 MatNavListItemHarness.prototype.isFocused = function () {
800 return __awaiter(this, void 0, void 0, function () {
801 return __generator(this, function (_a) {
802 switch (_a.label) {
803 case 0: return [4 /*yield*/, this.host()];
804 case 1: return [2 /*return*/, (_a.sent()).isFocused()];
805 }
806 });
807 });
808 };
809 return MatNavListItemHarness;
810 }(MatListItemHarnessBase));
811 /** The selector for the host element of a `MatListItem` instance. */
812 MatNavListItemHarness.hostSelector = MatNavListHarness.hostSelector + " .mat-list-item";
813
814 /** Harness for interacting with a standard mat-selection-list in tests. */
815 var MatSelectionListHarness = /** @class */ (function (_super) {
816 __extends(MatSelectionListHarness, _super);
817 function MatSelectionListHarness() {
818 var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
819 _this._itemHarness = MatListOptionHarness;
820 return _this;
821 }
822 /**
823 * Gets a `HarnessPredicate` that can be used to search for a `MatSelectionListHarness` that meets
824 * certain criteria.
825 * @param options Options for filtering which selection list instances are considered a match.
826 * @return a `HarnessPredicate` configured with the given options.
827 */
828 MatSelectionListHarness.with = function (options) {
829 if (options === void 0) { options = {}; }
830 return new testing.HarnessPredicate(MatSelectionListHarness, options);
831 };
832 /** Whether the selection list is disabled. */
833 MatSelectionListHarness.prototype.isDisabled = function () {
834 return __awaiter(this, void 0, void 0, function () {
835 return __generator(this, function (_a) {
836 switch (_a.label) {
837 case 0: return [4 /*yield*/, this.host()];
838 case 1: return [4 /*yield*/, (_a.sent()).getAttribute('aria-disabled')];
839 case 2: return [2 /*return*/, (_a.sent()) === 'true'];
840 }
841 });
842 });
843 };
844 /**
845 * Selects all items matching any of the given filters.
846 * @param filters Filters that specify which items should be selected.
847 */
848 MatSelectionListHarness.prototype.selectItems = function () {
849 var filters = [];
850 for (var _i = 0; _i < arguments.length; _i++) {
851 filters[_i] = arguments[_i];
852 }
853 return __awaiter(this, void 0, void 0, function () {
854 var items;
855 return __generator(this, function (_a) {
856 switch (_a.label) {
857 case 0: return [4 /*yield*/, this._getItems(filters)];
858 case 1:
859 items = _a.sent();
860 return [4 /*yield*/, testing.parallel(function () { return items.map(function (item) { return item.select(); }); })];
861 case 2:
862 _a.sent();
863 return [2 /*return*/];
864 }
865 });
866 });
867 };
868 /**
869 * Deselects all items matching any of the given filters.
870 * @param filters Filters that specify which items should be deselected.
871 */
872 MatSelectionListHarness.prototype.deselectItems = function () {
873 var filters = [];
874 for (var _i = 0; _i < arguments.length; _i++) {
875 filters[_i] = arguments[_i];
876 }
877 return __awaiter(this, void 0, void 0, function () {
878 var items;
879 return __generator(this, function (_a) {
880 switch (_a.label) {
881 case 0: return [4 /*yield*/, this._getItems(filters)];
882 case 1:
883 items = _a.sent();
884 return [4 /*yield*/, testing.parallel(function () { return items.map(function (item) { return item.deselect(); }); })];
885 case 2:
886 _a.sent();
887 return [2 /*return*/];
888 }
889 });
890 });
891 };
892 /** Gets all items matching the given list of filters. */
893 MatSelectionListHarness.prototype._getItems = function (filters) {
894 return __awaiter(this, void 0, void 0, function () {
895 var matches;
896 var _this = this;
897 return __generator(this, function (_a) {
898 switch (_a.label) {
899 case 0:
900 if (!filters.length) {
901 return [2 /*return*/, this.getItems()];
902 }
903 return [4 /*yield*/, testing.parallel(function () {
904 return filters.map(function (filter) { return _this.locatorForAll(MatListOptionHarness.with(filter))(); });
905 })];
906 case 1:
907 matches = _a.sent();
908 return [2 /*return*/, matches.reduce(function (result, current) { return __spreadArray(__spreadArray([], __read(result)), __read(current)); }, [])];
909 }
910 });
911 });
912 };
913 return MatSelectionListHarness;
914 }(MatListHarnessBase));
915 /** The selector for the host element of a `MatSelectionList` instance. */
916 MatSelectionListHarness.hostSelector = '.mat-selection-list';
917 /** Harness for interacting with a list option. */
918 var MatListOptionHarness = /** @class */ (function (_super) {
919 __extends(MatListOptionHarness, _super);
920 function MatListOptionHarness() {
921 var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
922 _this._itemContent = _this.locatorFor('.mat-list-item-content');
923 return _this;
924 }
925 /**
926 * Gets a `HarnessPredicate` that can be used to search for a `MatListOptionHarness` that
927 * meets certain criteria.
928 * @param options Options for filtering which list option instances are considered a match.
929 * @return a `HarnessPredicate` configured with the given options.
930 */
931 MatListOptionHarness.with = function (options) {
932 var _this = this;
933 if (options === void 0) { options = {}; }
934 return getListItemPredicate(MatListOptionHarness, options)
935 .addOption('is selected', options.selected, function (harness, selected) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
936 switch (_a.label) {
937 case 0: return [4 /*yield*/, harness.isSelected()];
938 case 1: return [2 /*return*/, (_a.sent()) === selected];
939 }
940 }); }); });
941 };
942 /** Gets the position of the checkbox relative to the list option content. */
943 MatListOptionHarness.prototype.getCheckboxPosition = function () {
944 return __awaiter(this, void 0, void 0, function () {
945 return __generator(this, function (_a) {
946 switch (_a.label) {
947 case 0: return [4 /*yield*/, this._itemContent()];
948 case 1: return [4 /*yield*/, (_a.sent()).hasClass('mat-list-item-content-reverse')];
949 case 2: return [2 /*return*/, (_a.sent()) ?
950 'after' : 'before'];
951 }
952 });
953 });
954 };
955 /** Whether the list option is selected. */
956 MatListOptionHarness.prototype.isSelected = function () {
957 return __awaiter(this, void 0, void 0, function () {
958 return __generator(this, function (_a) {
959 switch (_a.label) {
960 case 0: return [4 /*yield*/, this.host()];
961 case 1: return [4 /*yield*/, (_a.sent()).getAttribute('aria-selected')];
962 case 2: return [2 /*return*/, (_a.sent()) === 'true'];
963 }
964 });
965 });
966 };
967 /** Whether the list option is disabled. */
968 MatListOptionHarness.prototype.isDisabled = function () {
969 return __awaiter(this, void 0, void 0, function () {
970 return __generator(this, function (_a) {
971 switch (_a.label) {
972 case 0: return [4 /*yield*/, this.host()];
973 case 1: return [4 /*yield*/, (_a.sent()).getAttribute('aria-disabled')];
974 case 2: return [2 /*return*/, (_a.sent()) === 'true'];
975 }
976 });
977 });
978 };
979 /** Focuses the list option. */
980 MatListOptionHarness.prototype.focus = function () {
981 return __awaiter(this, void 0, void 0, function () {
982 return __generator(this, function (_a) {
983 switch (_a.label) {
984 case 0: return [4 /*yield*/, this.host()];
985 case 1: return [2 /*return*/, (_a.sent()).focus()];
986 }
987 });
988 });
989 };
990 /** Blurs the list option. */
991 MatListOptionHarness.prototype.blur = function () {
992 return __awaiter(this, void 0, void 0, function () {
993 return __generator(this, function (_a) {
994 switch (_a.label) {
995 case 0: return [4 /*yield*/, this.host()];
996 case 1: return [2 /*return*/, (_a.sent()).blur()];
997 }
998 });
999 });
1000 };
1001 /** Whether the list option is focused. */
1002 MatListOptionHarness.prototype.isFocused = function () {
1003 return __awaiter(this, void 0, void 0, function () {
1004 return __generator(this, function (_a) {
1005 switch (_a.label) {
1006 case 0: return [4 /*yield*/, this.host()];
1007 case 1: return [2 /*return*/, (_a.sent()).isFocused()];
1008 }
1009 });
1010 });
1011 };
1012 /** Toggles the checked state of the checkbox. */
1013 MatListOptionHarness.prototype.toggle = function () {
1014 return __awaiter(this, void 0, void 0, function () {
1015 return __generator(this, function (_a) {
1016 switch (_a.label) {
1017 case 0: return [4 /*yield*/, this.host()];
1018 case 1: return [2 /*return*/, (_a.sent()).click()];
1019 }
1020 });
1021 });
1022 };
1023 /**
1024 * Puts the list option in a checked state by toggling it if it is currently unchecked, or doing
1025 * nothing if it is already checked.
1026 */
1027 MatListOptionHarness.prototype.select = function () {
1028 return __awaiter(this, void 0, void 0, function () {
1029 return __generator(this, function (_a) {
1030 switch (_a.label) {
1031 case 0: return [4 /*yield*/, this.isSelected()];
1032 case 1:
1033 if (!(_a.sent())) {
1034 return [2 /*return*/, this.toggle()];
1035 }
1036 return [2 /*return*/];
1037 }
1038 });
1039 });
1040 };
1041 /**
1042 * Puts the list option in an unchecked state by toggling it if it is currently checked, or doing
1043 * nothing if it is already unchecked.
1044 */
1045 MatListOptionHarness.prototype.deselect = function () {
1046 return __awaiter(this, void 0, void 0, function () {
1047 return __generator(this, function (_a) {
1048 switch (_a.label) {
1049 case 0: return [4 /*yield*/, this.isSelected()];
1050 case 1:
1051 if (_a.sent()) {
1052 return [2 /*return*/, this.toggle()];
1053 }
1054 return [2 /*return*/];
1055 }
1056 });
1057 });
1058 };
1059 return MatListOptionHarness;
1060 }(MatListItemHarnessBase));
1061 /** The selector for the host element of a `MatListOption` instance. */
1062 MatListOptionHarness.hostSelector = '.mat-list-option';
1063
1064 /**
1065 * @license
1066 * Copyright Google LLC All Rights Reserved.
1067 *
1068 * Use of this source code is governed by an MIT-style license that can be
1069 * found in the LICENSE file at https://angular.io/license
1070 */
1071
1072 /**
1073 * @license
1074 * Copyright Google LLC All Rights Reserved.
1075 *
1076 * Use of this source code is governed by an MIT-style license that can be
1077 * found in the LICENSE file at https://angular.io/license
1078 */
1079
1080 exports.MatActionListHarness = MatActionListHarness;
1081 exports.MatActionListItemHarness = MatActionListItemHarness;
1082 exports.MatListHarness = MatListHarness;
1083 exports.MatListItemHarness = MatListItemHarness;
1084 exports.MatListOptionHarness = MatListOptionHarness;
1085 exports.MatNavListHarness = MatNavListHarness;
1086 exports.MatNavListItemHarness = MatNavListItemHarness;
1087 exports.MatSelectionListHarness = MatSelectionListHarness;
1088
1089 Object.defineProperty(exports, '__esModule', { value: true });
1090
1091})));
1092//# sourceMappingURL=material-list-testing.umd.js.map
Note: See TracBrowser for help on using the repository browser.