source: trip-planner-front/node_modules/@angular/material/bundles/material-datepicker-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: 65.0 KB
RevLine 
[6a3a178]1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/testing'), require('@angular/material/form-field/testing/control'), require('@angular/cdk/coercion')) :
3 typeof define === 'function' && define.amd ? define('@angular/material/datepicker/testing', ['exports', '@angular/cdk/testing', '@angular/material/form-field/testing/control', '@angular/cdk/coercion'], factory) :
4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ng = global.ng || {}, global.ng.material = global.ng.material || {}, global.ng.material.datepicker = global.ng.material.datepicker || {}, global.ng.material.datepicker.testing = {}), global.ng.cdk.testing, global.ng.material.formField.testing.control, global.ng.cdk.coercion));
5}(this, (function (exports, testing, control, coercion) { '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 /** Sets up the filter predicates for a datepicker input harness. */
326 function getInputPredicate(type, options) {
327 return new testing.HarnessPredicate(type, options)
328 .addOption('value', options.value, function (harness, value) {
329 return testing.HarnessPredicate.stringMatches(harness.getValue(), value);
330 })
331 .addOption('placeholder', options.placeholder, function (harness, placeholder) {
332 return testing.HarnessPredicate.stringMatches(harness.getPlaceholder(), placeholder);
333 });
334 }
335 /** Base class for datepicker input harnesses. */
336 var MatDatepickerInputHarnessBase = /** @class */ (function (_super) {
337 __extends(MatDatepickerInputHarnessBase, _super);
338 function MatDatepickerInputHarnessBase() {
339 return _super !== null && _super.apply(this, arguments) || this;
340 }
341 /** Whether the input is disabled. */
342 MatDatepickerInputHarnessBase.prototype.isDisabled = function () {
343 return __awaiter(this, void 0, void 0, function () {
344 return __generator(this, function (_a) {
345 switch (_a.label) {
346 case 0: return [4 /*yield*/, this.host()];
347 case 1: return [2 /*return*/, (_a.sent()).getProperty('disabled')];
348 }
349 });
350 });
351 };
352 /** Whether the input is required. */
353 MatDatepickerInputHarnessBase.prototype.isRequired = function () {
354 return __awaiter(this, void 0, void 0, function () {
355 return __generator(this, function (_a) {
356 switch (_a.label) {
357 case 0: return [4 /*yield*/, this.host()];
358 case 1: return [2 /*return*/, (_a.sent()).getProperty('required')];
359 }
360 });
361 });
362 };
363 /** Gets the value of the input. */
364 MatDatepickerInputHarnessBase.prototype.getValue = function () {
365 return __awaiter(this, void 0, void 0, function () {
366 return __generator(this, function (_a) {
367 switch (_a.label) {
368 case 0: return [4 /*yield*/, this.host()];
369 case 1: return [4 /*yield*/, (_a.sent()).getProperty('value')];
370 case 2:
371 // The "value" property of the native input is always defined.
372 return [2 /*return*/, (_a.sent())];
373 }
374 });
375 });
376 };
377 /**
378 * Sets the value of the input. The value will be set by simulating
379 * keypresses that correspond to the given value.
380 */
381 MatDatepickerInputHarnessBase.prototype.setValue = function (newValue) {
382 return __awaiter(this, void 0, void 0, function () {
383 var inputEl;
384 return __generator(this, function (_a) {
385 switch (_a.label) {
386 case 0: return [4 /*yield*/, this.host()];
387 case 1:
388 inputEl = _a.sent();
389 return [4 /*yield*/, inputEl.clear()];
390 case 2:
391 _a.sent();
392 if (!newValue) return [3 /*break*/, 4];
393 return [4 /*yield*/, inputEl.sendKeys(newValue)];
394 case 3:
395 _a.sent();
396 _a.label = 4;
397 case 4: return [4 /*yield*/, inputEl.dispatchEvent('change')];
398 case 5:
399 _a.sent();
400 return [2 /*return*/];
401 }
402 });
403 });
404 };
405 /** Gets the placeholder of the input. */
406 MatDatepickerInputHarnessBase.prototype.getPlaceholder = function () {
407 return __awaiter(this, void 0, void 0, function () {
408 return __generator(this, function (_a) {
409 switch (_a.label) {
410 case 0: return [4 /*yield*/, this.host()];
411 case 1: return [4 /*yield*/, (_a.sent()).getProperty('placeholder')];
412 case 2: return [2 /*return*/, (_a.sent())];
413 }
414 });
415 });
416 };
417 /**
418 * Focuses the input and returns a promise that indicates when the
419 * action is complete.
420 */
421 MatDatepickerInputHarnessBase.prototype.focus = function () {
422 return __awaiter(this, void 0, void 0, function () {
423 return __generator(this, function (_a) {
424 switch (_a.label) {
425 case 0: return [4 /*yield*/, this.host()];
426 case 1: return [2 /*return*/, (_a.sent()).focus()];
427 }
428 });
429 });
430 };
431 /**
432 * Blurs the input and returns a promise that indicates when the
433 * action is complete.
434 */
435 MatDatepickerInputHarnessBase.prototype.blur = function () {
436 return __awaiter(this, void 0, void 0, function () {
437 return __generator(this, function (_a) {
438 switch (_a.label) {
439 case 0: return [4 /*yield*/, this.host()];
440 case 1: return [2 /*return*/, (_a.sent()).blur()];
441 }
442 });
443 });
444 };
445 /** Whether the input is focused. */
446 MatDatepickerInputHarnessBase.prototype.isFocused = function () {
447 return __awaiter(this, void 0, void 0, function () {
448 return __generator(this, function (_a) {
449 switch (_a.label) {
450 case 0: return [4 /*yield*/, this.host()];
451 case 1: return [2 /*return*/, (_a.sent()).isFocused()];
452 }
453 });
454 });
455 };
456 /** Gets the formatted minimum date for the input's value. */
457 MatDatepickerInputHarnessBase.prototype.getMin = function () {
458 return __awaiter(this, void 0, void 0, function () {
459 return __generator(this, function (_a) {
460 switch (_a.label) {
461 case 0: return [4 /*yield*/, this.host()];
462 case 1: return [2 /*return*/, (_a.sent()).getAttribute('min')];
463 }
464 });
465 });
466 };
467 /** Gets the formatted maximum date for the input's value. */
468 MatDatepickerInputHarnessBase.prototype.getMax = function () {
469 return __awaiter(this, void 0, void 0, function () {
470 return __generator(this, function (_a) {
471 switch (_a.label) {
472 case 0: return [4 /*yield*/, this.host()];
473 case 1: return [2 /*return*/, (_a.sent()).getAttribute('max')];
474 }
475 });
476 });
477 };
478 return MatDatepickerInputHarnessBase;
479 }(control.MatFormFieldControlHarness));
480
481 /** Harness for interacting with a standard Material calendar cell in tests. */
482 var MatCalendarCellHarness = /** @class */ (function (_super) {
483 __extends(MatCalendarCellHarness, _super);
484 function MatCalendarCellHarness() {
485 var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
486 /** Reference to the inner content element inside the cell. */
487 _this._content = _this.locatorFor('.mat-calendar-body-cell-content');
488 return _this;
489 }
490 /**
491 * Gets a `HarnessPredicate` that can be used to search for a `MatCalendarCellHarness`
492 * that meets certain criteria.
493 * @param options Options for filtering which cell instances are considered a match.
494 * @return a `HarnessPredicate` configured with the given options.
495 */
496 MatCalendarCellHarness.with = function (options) {
497 var _this = this;
498 if (options === void 0) { options = {}; }
499 return new testing.HarnessPredicate(MatCalendarCellHarness, options)
500 .addOption('text', options.text, function (harness, text) {
501 return testing.HarnessPredicate.stringMatches(harness.getText(), text);
502 })
503 .addOption('selected', options.selected, function (harness, selected) { return __awaiter(_this, void 0, void 0, function () {
504 return __generator(this, function (_a) {
505 switch (_a.label) {
506 case 0: return [4 /*yield*/, harness.isSelected()];
507 case 1: return [2 /*return*/, (_a.sent()) === selected];
508 }
509 });
510 }); })
511 .addOption('active', options.active, function (harness, active) { return __awaiter(_this, void 0, void 0, function () {
512 return __generator(this, function (_a) {
513 switch (_a.label) {
514 case 0: return [4 /*yield*/, harness.isActive()];
515 case 1: return [2 /*return*/, (_a.sent()) === active];
516 }
517 });
518 }); })
519 .addOption('disabled', options.disabled, function (harness, disabled) { return __awaiter(_this, void 0, void 0, function () {
520 return __generator(this, function (_a) {
521 switch (_a.label) {
522 case 0: return [4 /*yield*/, harness.isDisabled()];
523 case 1: return [2 /*return*/, (_a.sent()) === disabled];
524 }
525 });
526 }); })
527 .addOption('today', options.today, function (harness, today) { return __awaiter(_this, void 0, void 0, function () {
528 return __generator(this, function (_a) {
529 switch (_a.label) {
530 case 0: return [4 /*yield*/, harness.isToday()];
531 case 1: return [2 /*return*/, (_a.sent()) === today];
532 }
533 });
534 }); })
535 .addOption('inRange', options.inRange, function (harness, inRange) { return __awaiter(_this, void 0, void 0, function () {
536 return __generator(this, function (_a) {
537 switch (_a.label) {
538 case 0: return [4 /*yield*/, harness.isInRange()];
539 case 1: return [2 /*return*/, (_a.sent()) === inRange];
540 }
541 });
542 }); })
543 .addOption('inComparisonRange', options.inComparisonRange, function (harness, inComparisonRange) { return __awaiter(_this, void 0, void 0, function () {
544 return __generator(this, function (_a) {
545 switch (_a.label) {
546 case 0: return [4 /*yield*/, harness.isInComparisonRange()];
547 case 1: return [2 /*return*/, (_a.sent()) === inComparisonRange];
548 }
549 });
550 }); })
551 .addOption('inPreviewRange', options.inPreviewRange, function (harness, inPreviewRange) { return __awaiter(_this, void 0, void 0, function () {
552 return __generator(this, function (_a) {
553 switch (_a.label) {
554 case 0: return [4 /*yield*/, harness.isInPreviewRange()];
555 case 1: return [2 /*return*/, (_a.sent()) === inPreviewRange];
556 }
557 });
558 }); });
559 };
560 /** Gets the text of the calendar cell. */
561 MatCalendarCellHarness.prototype.getText = function () {
562 return __awaiter(this, void 0, void 0, function () {
563 return __generator(this, function (_a) {
564 switch (_a.label) {
565 case 0: return [4 /*yield*/, this._content()];
566 case 1: return [2 /*return*/, (_a.sent()).text()];
567 }
568 });
569 });
570 };
571 /** Gets the aria-label of the calendar cell. */
572 MatCalendarCellHarness.prototype.getAriaLabel = function () {
573 return __awaiter(this, void 0, void 0, function () {
574 return __generator(this, function (_a) {
575 switch (_a.label) {
576 case 0: return [4 /*yield*/, this.host()];
577 case 1:
578 // We're guaranteed for the `aria-label` to be defined
579 // since this is a private element that we control.
580 return [2 /*return*/, (_a.sent()).getAttribute('aria-label')];
581 }
582 });
583 });
584 };
585 /** Whether the cell is selected. */
586 MatCalendarCellHarness.prototype.isSelected = function () {
587 return __awaiter(this, void 0, void 0, function () {
588 var host;
589 return __generator(this, function (_a) {
590 switch (_a.label) {
591 case 0: return [4 /*yield*/, this.host()];
592 case 1:
593 host = _a.sent();
594 return [4 /*yield*/, host.getAttribute('aria-selected')];
595 case 2: return [2 /*return*/, (_a.sent()) === 'true'];
596 }
597 });
598 });
599 };
600 /** Whether the cell is disabled. */
601 MatCalendarCellHarness.prototype.isDisabled = function () {
602 return __awaiter(this, void 0, void 0, function () {
603 return __generator(this, function (_a) {
604 return [2 /*return*/, this._hasState('disabled')];
605 });
606 });
607 };
608 /** Whether the cell is currently activated using keyboard navigation. */
609 MatCalendarCellHarness.prototype.isActive = function () {
610 return __awaiter(this, void 0, void 0, function () {
611 return __generator(this, function (_a) {
612 return [2 /*return*/, this._hasState('active')];
613 });
614 });
615 };
616 /** Whether the cell represents today's date. */
617 MatCalendarCellHarness.prototype.isToday = function () {
618 return __awaiter(this, void 0, void 0, function () {
619 return __generator(this, function (_a) {
620 switch (_a.label) {
621 case 0: return [4 /*yield*/, this._content()];
622 case 1: return [2 /*return*/, (_a.sent()).hasClass('mat-calendar-body-today')];
623 }
624 });
625 });
626 };
627 /** Selects the calendar cell. Won't do anything if the cell is disabled. */
628 MatCalendarCellHarness.prototype.select = function () {
629 return __awaiter(this, void 0, void 0, function () {
630 return __generator(this, function (_a) {
631 switch (_a.label) {
632 case 0: return [4 /*yield*/, this.host()];
633 case 1: return [2 /*return*/, (_a.sent()).click()];
634 }
635 });
636 });
637 };
638 /** Hovers over the calendar cell. */
639 MatCalendarCellHarness.prototype.hover = function () {
640 return __awaiter(this, void 0, void 0, function () {
641 return __generator(this, function (_a) {
642 switch (_a.label) {
643 case 0: return [4 /*yield*/, this.host()];
644 case 1: return [2 /*return*/, (_a.sent()).hover()];
645 }
646 });
647 });
648 };
649 /** Moves the mouse away from the calendar cell. */
650 MatCalendarCellHarness.prototype.mouseAway = function () {
651 return __awaiter(this, void 0, void 0, function () {
652 return __generator(this, function (_a) {
653 switch (_a.label) {
654 case 0: return [4 /*yield*/, this.host()];
655 case 1: return [2 /*return*/, (_a.sent()).mouseAway()];
656 }
657 });
658 });
659 };
660 /** Focuses the calendar cell. */
661 MatCalendarCellHarness.prototype.focus = function () {
662 return __awaiter(this, void 0, void 0, function () {
663 return __generator(this, function (_a) {
664 switch (_a.label) {
665 case 0: return [4 /*yield*/, this.host()];
666 case 1: return [2 /*return*/, (_a.sent()).focus()];
667 }
668 });
669 });
670 };
671 /** Removes focus from the calendar cell. */
672 MatCalendarCellHarness.prototype.blur = function () {
673 return __awaiter(this, void 0, void 0, function () {
674 return __generator(this, function (_a) {
675 switch (_a.label) {
676 case 0: return [4 /*yield*/, this.host()];
677 case 1: return [2 /*return*/, (_a.sent()).blur()];
678 }
679 });
680 });
681 };
682 /** Whether the cell is the start of the main range. */
683 MatCalendarCellHarness.prototype.isRangeStart = function () {
684 return __awaiter(this, void 0, void 0, function () {
685 return __generator(this, function (_a) {
686 return [2 /*return*/, this._hasState('range-start')];
687 });
688 });
689 };
690 /** Whether the cell is the end of the main range. */
691 MatCalendarCellHarness.prototype.isRangeEnd = function () {
692 return __awaiter(this, void 0, void 0, function () {
693 return __generator(this, function (_a) {
694 return [2 /*return*/, this._hasState('range-end')];
695 });
696 });
697 };
698 /** Whether the cell is part of the main range. */
699 MatCalendarCellHarness.prototype.isInRange = function () {
700 return __awaiter(this, void 0, void 0, function () {
701 return __generator(this, function (_a) {
702 return [2 /*return*/, this._hasState('in-range')];
703 });
704 });
705 };
706 /** Whether the cell is the start of the comparison range. */
707 MatCalendarCellHarness.prototype.isComparisonRangeStart = function () {
708 return __awaiter(this, void 0, void 0, function () {
709 return __generator(this, function (_a) {
710 return [2 /*return*/, this._hasState('comparison-start')];
711 });
712 });
713 };
714 /** Whether the cell is the end of the comparison range. */
715 MatCalendarCellHarness.prototype.isComparisonRangeEnd = function () {
716 return __awaiter(this, void 0, void 0, function () {
717 return __generator(this, function (_a) {
718 return [2 /*return*/, this._hasState('comparison-end')];
719 });
720 });
721 };
722 /** Whether the cell is inside of the comparison range. */
723 MatCalendarCellHarness.prototype.isInComparisonRange = function () {
724 return __awaiter(this, void 0, void 0, function () {
725 return __generator(this, function (_a) {
726 return [2 /*return*/, this._hasState('in-comparison-range')];
727 });
728 });
729 };
730 /** Whether the cell is the start of the preview range. */
731 MatCalendarCellHarness.prototype.isPreviewRangeStart = function () {
732 return __awaiter(this, void 0, void 0, function () {
733 return __generator(this, function (_a) {
734 return [2 /*return*/, this._hasState('preview-start')];
735 });
736 });
737 };
738 /** Whether the cell is the end of the preview range. */
739 MatCalendarCellHarness.prototype.isPreviewRangeEnd = function () {
740 return __awaiter(this, void 0, void 0, function () {
741 return __generator(this, function (_a) {
742 return [2 /*return*/, this._hasState('preview-end')];
743 });
744 });
745 };
746 /** Whether the cell is inside of the preview range. */
747 MatCalendarCellHarness.prototype.isInPreviewRange = function () {
748 return __awaiter(this, void 0, void 0, function () {
749 return __generator(this, function (_a) {
750 return [2 /*return*/, this._hasState('in-preview')];
751 });
752 });
753 };
754 /** Returns whether the cell has a particular CSS class-based state. */
755 MatCalendarCellHarness.prototype._hasState = function (name) {
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()).hasClass("mat-calendar-body-" + name)];
761 }
762 });
763 });
764 };
765 return MatCalendarCellHarness;
766 }(testing.ComponentHarness));
767 MatCalendarCellHarness.hostSelector = '.mat-calendar-body-cell';
768
769 /** Harness for interacting with a standard Material calendar in tests. */
770 var MatCalendarHarness = /** @class */ (function (_super) {
771 __extends(MatCalendarHarness, _super);
772 function MatCalendarHarness() {
773 var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
774 /** Queries for the calendar's period toggle button. */
775 _this._periodButton = _this.locatorFor('.mat-calendar-period-button');
776 return _this;
777 }
778 /**
779 * Gets a `HarnessPredicate` that can be used to search for a `MatCalendarHarness`
780 * that meets certain criteria.
781 * @param options Options for filtering which calendar instances are considered a match.
782 * @return a `HarnessPredicate` configured with the given options.
783 */
784 MatCalendarHarness.with = function (options) {
785 if (options === void 0) { options = {}; }
786 return new testing.HarnessPredicate(MatCalendarHarness, options);
787 };
788 /**
789 * Gets a list of cells inside the calendar.
790 * @param filter Optionally filters which cells are included.
791 */
792 MatCalendarHarness.prototype.getCells = function (filter) {
793 if (filter === void 0) { filter = {}; }
794 return __awaiter(this, void 0, void 0, function () {
795 return __generator(this, function (_a) {
796 return [2 /*return*/, this.locatorForAll(MatCalendarCellHarness.with(filter))()];
797 });
798 });
799 };
800 /** Gets the current view that is being shown inside the calendar. */
801 MatCalendarHarness.prototype.getCurrentView = function () {
802 return __awaiter(this, void 0, void 0, function () {
803 return __generator(this, function (_a) {
804 switch (_a.label) {
805 case 0: return [4 /*yield*/, this.locatorForOptional('mat-multi-year-view')()];
806 case 1:
807 if (_a.sent()) {
808 return [2 /*return*/, 2 /* MULTI_YEAR */];
809 }
810 return [4 /*yield*/, this.locatorForOptional('mat-year-view')()];
811 case 2:
812 if (_a.sent()) {
813 return [2 /*return*/, 1 /* YEAR */];
814 }
815 return [2 /*return*/, 0 /* MONTH */];
816 }
817 });
818 });
819 };
820 /** Gets the label of the current calendar view. */
821 MatCalendarHarness.prototype.getCurrentViewLabel = function () {
822 return __awaiter(this, void 0, void 0, function () {
823 return __generator(this, function (_a) {
824 switch (_a.label) {
825 case 0: return [4 /*yield*/, this._periodButton()];
826 case 1: return [2 /*return*/, (_a.sent()).text()];
827 }
828 });
829 });
830 };
831 /** Changes the calendar view by clicking on the view toggle button. */
832 MatCalendarHarness.prototype.changeView = function () {
833 return __awaiter(this, void 0, void 0, function () {
834 return __generator(this, function (_a) {
835 switch (_a.label) {
836 case 0: return [4 /*yield*/, this._periodButton()];
837 case 1: return [2 /*return*/, (_a.sent()).click()];
838 }
839 });
840 });
841 };
842 /** Goes to the next page of the current view (e.g. next month when inside the month view). */
843 MatCalendarHarness.prototype.next = function () {
844 return __awaiter(this, void 0, void 0, function () {
845 return __generator(this, function (_a) {
846 switch (_a.label) {
847 case 0: return [4 /*yield*/, this.locatorFor('.mat-calendar-next-button')()];
848 case 1: return [2 /*return*/, (_a.sent()).click()];
849 }
850 });
851 });
852 };
853 /**
854 * Goes to the previous page of the current view
855 * (e.g. previous month when inside the month view).
856 */
857 MatCalendarHarness.prototype.previous = function () {
858 return __awaiter(this, void 0, void 0, function () {
859 return __generator(this, function (_a) {
860 switch (_a.label) {
861 case 0: return [4 /*yield*/, this.locatorFor('.mat-calendar-previous-button')()];
862 case 1: return [2 /*return*/, (_a.sent()).click()];
863 }
864 });
865 });
866 };
867 /**
868 * Selects a cell in the current calendar view.
869 * @param filter An optional filter to apply to the cells. The first cell matching the filter
870 * will be selected.
871 */
872 MatCalendarHarness.prototype.selectCell = function (filter) {
873 if (filter === void 0) { filter = {}; }
874 return __awaiter(this, void 0, void 0, function () {
875 var cells;
876 return __generator(this, function (_a) {
877 switch (_a.label) {
878 case 0: return [4 /*yield*/, this.getCells(filter)];
879 case 1:
880 cells = _a.sent();
881 if (!cells.length) {
882 throw Error("Cannot find calendar cell matching filter " + JSON.stringify(filter));
883 }
884 return [4 /*yield*/, cells[0].select()];
885 case 2:
886 _a.sent();
887 return [2 /*return*/];
888 }
889 });
890 });
891 };
892 return MatCalendarHarness;
893 }(testing.ComponentHarness));
894 MatCalendarHarness.hostSelector = '.mat-calendar';
895
896 /** Base class for harnesses that can trigger a calendar. */
897 var DatepickerTriggerHarnessBase = /** @class */ (function (_super) {
898 __extends(DatepickerTriggerHarnessBase, _super);
899 function DatepickerTriggerHarnessBase() {
900 return _super !== null && _super.apply(this, arguments) || this;
901 }
902 /** Opens the calendar if the trigger is enabled and it has a calendar. */
903 DatepickerTriggerHarnessBase.prototype.openCalendar = function () {
904 return __awaiter(this, void 0, void 0, function () {
905 var _a, isDisabled, hasCalendar;
906 var _this = this;
907 return __generator(this, function (_b) {
908 switch (_b.label) {
909 case 0: return [4 /*yield*/, testing.parallel(function () { return [_this.isDisabled(), _this.hasCalendar()]; })];
910 case 1:
911 _a = __read.apply(void 0, [_b.sent(), 2]), isDisabled = _a[0], hasCalendar = _a[1];
912 if (!isDisabled && hasCalendar) {
913 return [2 /*return*/, this._openCalendar()];
914 }
915 return [2 /*return*/];
916 }
917 });
918 });
919 };
920 /** Closes the calendar if it is open. */
921 DatepickerTriggerHarnessBase.prototype.closeCalendar = function () {
922 return __awaiter(this, void 0, void 0, function () {
923 return __generator(this, function (_a) {
924 switch (_a.label) {
925 case 0: return [4 /*yield*/, this.isCalendarOpen()];
926 case 1:
927 if (!_a.sent()) return [3 /*break*/, 4];
928 return [4 /*yield*/, closeCalendar(getCalendarId(this.host()), this.documentRootLocatorFactory())];
929 case 2:
930 _a.sent();
931 // This is necessary so that we wait for the closing animation to finish in touch UI mode.
932 return [4 /*yield*/, this.forceStabilize()];
933 case 3:
934 // This is necessary so that we wait for the closing animation to finish in touch UI mode.
935 _a.sent();
936 _a.label = 4;
937 case 4: return [2 /*return*/];
938 }
939 });
940 });
941 };
942 /** Gets whether there is a calendar associated with the trigger. */
943 DatepickerTriggerHarnessBase.prototype.hasCalendar = 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*/, getCalendarId(this.host())];
948 case 1: return [2 /*return*/, (_a.sent()) != null];
949 }
950 });
951 });
952 };
953 /**
954 * Gets the `MatCalendarHarness` that is associated with the trigger.
955 * @param filter Optionally filters which calendar is included.
956 */
957 DatepickerTriggerHarnessBase.prototype.getCalendar = function (filter) {
958 if (filter === void 0) { filter = {}; }
959 return __awaiter(this, void 0, void 0, function () {
960 return __generator(this, function (_a) {
961 return [2 /*return*/, getCalendar(filter, this.host(), this.documentRootLocatorFactory())];
962 });
963 });
964 };
965 return DatepickerTriggerHarnessBase;
966 }(testing.ComponentHarness));
967 /** Gets the ID of the calendar that a particular test element can trigger. */
968 function getCalendarId(host) {
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*/, host];
973 case 1: return [2 /*return*/, (_a.sent()).getAttribute('data-mat-calendar')];
974 }
975 });
976 });
977 }
978 /** Closes the calendar with a specific ID. */
979 function closeCalendar(calendarId, documentLocator) {
980 return __awaiter(this, void 0, void 0, function () {
981 var backdropSelector, _a;
982 return __generator(this, function (_b) {
983 switch (_b.label) {
984 case 0:
985 _a = ".";
986 return [4 /*yield*/, calendarId];
987 case 1:
988 backdropSelector = _a + (_b.sent()) + "-backdrop";
989 return [4 /*yield*/, documentLocator.locatorFor(backdropSelector)()];
990 case 2: return [2 /*return*/, (_b.sent()).click()];
991 }
992 });
993 });
994 }
995 /** Gets the test harness for a calendar associated with a particular host. */
996 function getCalendar(filter, host, documentLocator) {
997 return __awaiter(this, void 0, void 0, function () {
998 var calendarId;
999 return __generator(this, function (_a) {
1000 switch (_a.label) {
1001 case 0: return [4 /*yield*/, getCalendarId(host)];
1002 case 1:
1003 calendarId = _a.sent();
1004 if (!calendarId) {
1005 throw Error("Element is not associated with a calendar");
1006 }
1007 return [2 /*return*/, documentLocator.locatorFor(MatCalendarHarness.with(Object.assign(Object.assign({}, filter), { selector: "#" + calendarId })))()];
1008 }
1009 });
1010 });
1011 }
1012
1013 /** Harness for interacting with a standard Material datepicker inputs in tests. */
1014 var MatDatepickerInputHarness = /** @class */ (function (_super) {
1015 __extends(MatDatepickerInputHarness, _super);
1016 function MatDatepickerInputHarness() {
1017 return _super !== null && _super.apply(this, arguments) || this;
1018 }
1019 /**
1020 * Gets a `HarnessPredicate` that can be used to search for a `MatDatepickerInputHarness`
1021 * that meets certain criteria.
1022 * @param options Options for filtering which input instances are considered a match.
1023 * @return a `HarnessPredicate` configured with the given options.
1024 */
1025 MatDatepickerInputHarness.with = function (options) {
1026 if (options === void 0) { options = {}; }
1027 return getInputPredicate(MatDatepickerInputHarness, options);
1028 };
1029 /** Gets whether the calendar associated with the input is open. */
1030 MatDatepickerInputHarness.prototype.isCalendarOpen = function () {
1031 return __awaiter(this, void 0, void 0, function () {
1032 var host;
1033 return __generator(this, function (_a) {
1034 switch (_a.label) {
1035 case 0: return [4 /*yield*/, this.host()];
1036 case 1:
1037 host = _a.sent();
1038 return [4 /*yield*/, host.getAttribute('aria-owns')];
1039 case 2: return [2 /*return*/, (_a.sent()) != null];
1040 }
1041 });
1042 });
1043 };
1044 /** Opens the calendar associated with the input. */
1045 MatDatepickerInputHarness.prototype.openCalendar = function () {
1046 return __awaiter(this, void 0, void 0, function () {
1047 var _a, isDisabled, hasCalendar, host;
1048 var _this = this;
1049 return __generator(this, function (_b) {
1050 switch (_b.label) {
1051 case 0: return [4 /*yield*/, testing.parallel(function () { return [_this.isDisabled(), _this.hasCalendar()]; })];
1052 case 1:
1053 _a = __read.apply(void 0, [_b.sent(), 2]), isDisabled = _a[0], hasCalendar = _a[1];
1054 if (!(!isDisabled && hasCalendar)) return [3 /*break*/, 3];
1055 return [4 /*yield*/, this.host()];
1056 case 2:
1057 host = _b.sent();
1058 return [2 /*return*/, host.sendKeys({ alt: true }, testing.TestKey.DOWN_ARROW)];
1059 case 3: return [2 /*return*/];
1060 }
1061 });
1062 });
1063 };
1064 /** Closes the calendar associated with the input. */
1065 MatDatepickerInputHarness.prototype.closeCalendar = function () {
1066 return __awaiter(this, void 0, void 0, function () {
1067 return __generator(this, function (_a) {
1068 switch (_a.label) {
1069 case 0: return [4 /*yield*/, this.isCalendarOpen()];
1070 case 1:
1071 if (!_a.sent()) return [3 /*break*/, 4];
1072 return [4 /*yield*/, closeCalendar(getCalendarId(this.host()), this.documentRootLocatorFactory())];
1073 case 2:
1074 _a.sent();
1075 // This is necessary so that we wait for the closing animation to finish in touch UI mode.
1076 return [4 /*yield*/, this.forceStabilize()];
1077 case 3:
1078 // This is necessary so that we wait for the closing animation to finish in touch UI mode.
1079 _a.sent();
1080 _a.label = 4;
1081 case 4: return [2 /*return*/];
1082 }
1083 });
1084 });
1085 };
1086 /** Whether a calendar is associated with the input. */
1087 MatDatepickerInputHarness.prototype.hasCalendar = function () {
1088 return __awaiter(this, void 0, void 0, function () {
1089 return __generator(this, function (_a) {
1090 switch (_a.label) {
1091 case 0: return [4 /*yield*/, getCalendarId(this.host())];
1092 case 1: return [2 /*return*/, (_a.sent()) != null];
1093 }
1094 });
1095 });
1096 };
1097 /**
1098 * Gets the `MatCalendarHarness` that is associated with the trigger.
1099 * @param filter Optionally filters which calendar is included.
1100 */
1101 MatDatepickerInputHarness.prototype.getCalendar = function (filter) {
1102 if (filter === void 0) { filter = {}; }
1103 return __awaiter(this, void 0, void 0, function () {
1104 return __generator(this, function (_a) {
1105 return [2 /*return*/, getCalendar(filter, this.host(), this.documentRootLocatorFactory())];
1106 });
1107 });
1108 };
1109 return MatDatepickerInputHarness;
1110 }(MatDatepickerInputHarnessBase));
1111 MatDatepickerInputHarness.hostSelector = '.mat-datepicker-input';
1112
1113 /** Harness for interacting with a standard Material datepicker toggle in tests. */
1114 var MatDatepickerToggleHarness = /** @class */ (function (_super) {
1115 __extends(MatDatepickerToggleHarness, _super);
1116 function MatDatepickerToggleHarness() {
1117 var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
1118 /** The clickable button inside the toggle. */
1119 _this._button = _this.locatorFor('button');
1120 return _this;
1121 }
1122 /**
1123 * Gets a `HarnessPredicate` that can be used to search for a `MatDatepickerToggleHarness` that
1124 * meets certain criteria.
1125 * @param options Options for filtering which datepicker toggle instances are considered a match.
1126 * @return a `HarnessPredicate` configured with the given options.
1127 */
1128 MatDatepickerToggleHarness.with = function (options) {
1129 if (options === void 0) { options = {}; }
1130 return new testing.HarnessPredicate(MatDatepickerToggleHarness, options);
1131 };
1132 /** Gets whether the calendar associated with the toggle is open. */
1133 MatDatepickerToggleHarness.prototype.isCalendarOpen = function () {
1134 return __awaiter(this, void 0, void 0, function () {
1135 return __generator(this, function (_a) {
1136 switch (_a.label) {
1137 case 0: return [4 /*yield*/, this.host()];
1138 case 1: return [2 /*return*/, (_a.sent()).hasClass('mat-datepicker-toggle-active')];
1139 }
1140 });
1141 });
1142 };
1143 /** Whether the toggle is disabled. */
1144 MatDatepickerToggleHarness.prototype.isDisabled = function () {
1145 return __awaiter(this, void 0, void 0, function () {
1146 var button, _a;
1147 return __generator(this, function (_b) {
1148 switch (_b.label) {
1149 case 0: return [4 /*yield*/, this._button()];
1150 case 1:
1151 button = _b.sent();
1152 _a = coercion.coerceBooleanProperty;
1153 return [4 /*yield*/, button.getAttribute('disabled')];
1154 case 2: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
1155 }
1156 });
1157 });
1158 };
1159 MatDatepickerToggleHarness.prototype._openCalendar = function () {
1160 return __awaiter(this, void 0, void 0, function () {
1161 return __generator(this, function (_a) {
1162 switch (_a.label) {
1163 case 0: return [4 /*yield*/, this._button()];
1164 case 1: return [2 /*return*/, (_a.sent()).click()];
1165 }
1166 });
1167 });
1168 };
1169 return MatDatepickerToggleHarness;
1170 }(DatepickerTriggerHarnessBase));
1171 MatDatepickerToggleHarness.hostSelector = '.mat-datepicker-toggle';
1172
1173 /** Harness for interacting with a standard Material date range start input in tests. */
1174 var MatStartDateHarness = /** @class */ (function (_super) {
1175 __extends(MatStartDateHarness, _super);
1176 function MatStartDateHarness() {
1177 return _super !== null && _super.apply(this, arguments) || this;
1178 }
1179 /**
1180 * Gets a `HarnessPredicate` that can be used to search for a `MatStartDateHarness`
1181 * that meets certain criteria.
1182 * @param options Options for filtering which input instances are considered a match.
1183 * @return a `HarnessPredicate` configured with the given options.
1184 */
1185 MatStartDateHarness.with = function (options) {
1186 if (options === void 0) { options = {}; }
1187 return getInputPredicate(MatStartDateHarness, options);
1188 };
1189 return MatStartDateHarness;
1190 }(MatDatepickerInputHarnessBase));
1191 MatStartDateHarness.hostSelector = '.mat-start-date';
1192 /** Harness for interacting with a standard Material date range end input in tests. */
1193 var MatEndDateHarness = /** @class */ (function (_super) {
1194 __extends(MatEndDateHarness, _super);
1195 function MatEndDateHarness() {
1196 return _super !== null && _super.apply(this, arguments) || this;
1197 }
1198 /**
1199 * Gets a `HarnessPredicate` that can be used to search for a `MatEndDateHarness`
1200 * that meets certain criteria.
1201 * @param options Options for filtering which input instances are considered a match.
1202 * @return a `HarnessPredicate` configured with the given options.
1203 */
1204 MatEndDateHarness.with = function (options) {
1205 if (options === void 0) { options = {}; }
1206 return getInputPredicate(MatEndDateHarness, options);
1207 };
1208 return MatEndDateHarness;
1209 }(MatDatepickerInputHarnessBase));
1210 MatEndDateHarness.hostSelector = '.mat-end-date';
1211 /** Harness for interacting with a standard Material date range input in tests. */
1212 var MatDateRangeInputHarness = /** @class */ (function (_super) {
1213 __extends(MatDateRangeInputHarness, _super);
1214 function MatDateRangeInputHarness() {
1215 return _super !== null && _super.apply(this, arguments) || this;
1216 }
1217 /**
1218 * Gets a `HarnessPredicate` that can be used to search for a `MatDateRangeInputHarness`
1219 * that meets certain criteria.
1220 * @param options Options for filtering which input instances are considered a match.
1221 * @return a `HarnessPredicate` configured with the given options.
1222 */
1223 MatDateRangeInputHarness.with = function (options) {
1224 if (options === void 0) { options = {}; }
1225 return new testing.HarnessPredicate(MatDateRangeInputHarness, options)
1226 .addOption('value', options.value, function (harness, value) { return testing.HarnessPredicate.stringMatches(harness.getValue(), value); });
1227 };
1228 /** Gets the combined value of the start and end inputs, including the separator. */
1229 MatDateRangeInputHarness.prototype.getValue = function () {
1230 return __awaiter(this, void 0, void 0, function () {
1231 var _a, start, end, separator;
1232 var _this = this;
1233 return __generator(this, function (_b) {
1234 switch (_b.label) {
1235 case 0: return [4 /*yield*/, testing.parallel(function () { return [
1236 _this.getStartInput().then(function (input) { return input.getValue(); }),
1237 _this.getEndInput().then(function (input) { return input.getValue(); }),
1238 _this.getSeparator()
1239 ]; })];
1240 case 1:
1241 _a = __read.apply(void 0, [_b.sent(), 3]), start = _a[0], end = _a[1], separator = _a[2];
1242 return [2 /*return*/, start + ("" + (end ? " " + separator + " " + end : ''))];
1243 }
1244 });
1245 });
1246 };
1247 /** Gets the inner start date input inside the range input. */
1248 MatDateRangeInputHarness.prototype.getStartInput = function () {
1249 return __awaiter(this, void 0, void 0, function () {
1250 return __generator(this, function (_a) {
1251 // Don't pass in filters here since the start input is required and there can only be one.
1252 return [2 /*return*/, this.locatorFor(MatStartDateHarness)()];
1253 });
1254 });
1255 };
1256 /** Gets the inner start date input inside the range input. */
1257 MatDateRangeInputHarness.prototype.getEndInput = function () {
1258 return __awaiter(this, void 0, void 0, function () {
1259 return __generator(this, function (_a) {
1260 // Don't pass in filters here since the end input is required and there can only be one.
1261 return [2 /*return*/, this.locatorFor(MatEndDateHarness)()];
1262 });
1263 });
1264 };
1265 /** Gets the separator text between the values of the two inputs. */
1266 MatDateRangeInputHarness.prototype.getSeparator = function () {
1267 return __awaiter(this, void 0, void 0, function () {
1268 return __generator(this, function (_a) {
1269 switch (_a.label) {
1270 case 0: return [4 /*yield*/, this.locatorFor('.mat-date-range-input-separator')()];
1271 case 1: return [2 /*return*/, (_a.sent()).text()];
1272 }
1273 });
1274 });
1275 };
1276 /** Gets whether the range input is disabled. */
1277 MatDateRangeInputHarness.prototype.isDisabled = function () {
1278 return __awaiter(this, void 0, void 0, function () {
1279 var _a, startDisabled, endDisabled;
1280 var _this = this;
1281 return __generator(this, function (_b) {
1282 switch (_b.label) {
1283 case 0: return [4 /*yield*/, testing.parallel(function () { return [
1284 _this.getStartInput().then(function (input) { return input.isDisabled(); }),
1285 _this.getEndInput().then(function (input) { return input.isDisabled(); })
1286 ]; })];
1287 case 1:
1288 _a = __read.apply(void 0, [_b.sent(), 2]), startDisabled = _a[0], endDisabled = _a[1];
1289 return [2 /*return*/, startDisabled && endDisabled];
1290 }
1291 });
1292 });
1293 };
1294 /** Gets whether the range input is required. */
1295 MatDateRangeInputHarness.prototype.isRequired = function () {
1296 return __awaiter(this, void 0, void 0, function () {
1297 return __generator(this, function (_a) {
1298 switch (_a.label) {
1299 case 0: return [4 /*yield*/, this.host()];
1300 case 1: return [2 /*return*/, (_a.sent()).hasClass('mat-date-range-input-required')];
1301 }
1302 });
1303 });
1304 };
1305 /** Opens the calendar associated with the input. */
1306 MatDateRangeInputHarness.prototype.isCalendarOpen = function () {
1307 return __awaiter(this, void 0, void 0, function () {
1308 var startHost;
1309 return __generator(this, function (_a) {
1310 switch (_a.label) {
1311 case 0: return [4 /*yield*/, this.getStartInput()];
1312 case 1: return [4 /*yield*/, (_a.sent()).host()];
1313 case 2:
1314 startHost = _a.sent();
1315 return [4 /*yield*/, startHost.getAttribute('aria-owns')];
1316 case 3: return [2 /*return*/, (_a.sent()) != null];
1317 }
1318 });
1319 });
1320 };
1321 MatDateRangeInputHarness.prototype._openCalendar = function () {
1322 return __awaiter(this, void 0, void 0, function () {
1323 var startHost;
1324 return __generator(this, function (_a) {
1325 switch (_a.label) {
1326 case 0: return [4 /*yield*/, this.getStartInput()];
1327 case 1: return [4 /*yield*/, (_a.sent()).host()];
1328 case 2:
1329 startHost = _a.sent();
1330 return [2 /*return*/, startHost.sendKeys({ alt: true }, testing.TestKey.DOWN_ARROW)];
1331 }
1332 });
1333 });
1334 };
1335 return MatDateRangeInputHarness;
1336 }(DatepickerTriggerHarnessBase));
1337 MatDateRangeInputHarness.hostSelector = '.mat-date-range-input';
1338
1339 /**
1340 * @license
1341 * Copyright Google LLC All Rights Reserved.
1342 *
1343 * Use of this source code is governed by an MIT-style license that can be
1344 * found in the LICENSE file at https://angular.io/license
1345 */
1346
1347 /**
1348 * @license
1349 * Copyright Google LLC All Rights Reserved.
1350 *
1351 * Use of this source code is governed by an MIT-style license that can be
1352 * found in the LICENSE file at https://angular.io/license
1353 */
1354
1355 exports.MatCalendarCellHarness = MatCalendarCellHarness;
1356 exports.MatCalendarHarness = MatCalendarHarness;
1357 exports.MatDateRangeInputHarness = MatDateRangeInputHarness;
1358 exports.MatDatepickerInputHarness = MatDatepickerInputHarness;
1359 exports.MatDatepickerToggleHarness = MatDatepickerToggleHarness;
1360 exports.MatEndDateHarness = MatEndDateHarness;
1361 exports.MatStartDateHarness = MatStartDateHarness;
1362
1363 Object.defineProperty(exports, '__esModule', { value: true });
1364
1365})));
1366//# sourceMappingURL=material-datepicker-testing.umd.js.map
Note: See TracBrowser for help on using the repository browser.