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

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

initial commit

  • Property mode set to 100644
File size: 9.2 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { __awaiter } from "tslib";
9import { parallel, TestKey } from '@angular/cdk/testing';
10import { MatDatepickerInputHarnessBase, getInputPredicate } from './datepicker-input-harness-base';
11import { closeCalendar, getCalendarId, getCalendar, } from './datepicker-trigger-harness-base';
12/** Harness for interacting with a standard Material datepicker inputs in tests. */
13export class MatDatepickerInputHarness extends MatDatepickerInputHarnessBase {
14 /**
15 * Gets a `HarnessPredicate` that can be used to search for a `MatDatepickerInputHarness`
16 * that meets certain criteria.
17 * @param options Options for filtering which input instances are considered a match.
18 * @return a `HarnessPredicate` configured with the given options.
19 */
20 static with(options = {}) {
21 return getInputPredicate(MatDatepickerInputHarness, options);
22 }
23 /** Gets whether the calendar associated with the input is open. */
24 isCalendarOpen() {
25 return __awaiter(this, void 0, void 0, function* () {
26 // `aria-owns` is set only if there's an open datepicker so we can use it as an indicator.
27 const host = yield this.host();
28 return (yield host.getAttribute('aria-owns')) != null;
29 });
30 }
31 /** Opens the calendar associated with the input. */
32 openCalendar() {
33 return __awaiter(this, void 0, void 0, function* () {
34 const [isDisabled, hasCalendar] = yield parallel(() => [this.isDisabled(), this.hasCalendar()]);
35 if (!isDisabled && hasCalendar) {
36 // Alt + down arrow is the combination for opening the calendar with the keyboard.
37 const host = yield this.host();
38 return host.sendKeys({ alt: true }, TestKey.DOWN_ARROW);
39 }
40 });
41 }
42 /** Closes the calendar associated with the input. */
43 closeCalendar() {
44 return __awaiter(this, void 0, void 0, function* () {
45 if (yield this.isCalendarOpen()) {
46 yield closeCalendar(getCalendarId(this.host()), this.documentRootLocatorFactory());
47 // This is necessary so that we wait for the closing animation to finish in touch UI mode.
48 yield this.forceStabilize();
49 }
50 });
51 }
52 /** Whether a calendar is associated with the input. */
53 hasCalendar() {
54 return __awaiter(this, void 0, void 0, function* () {
55 return (yield getCalendarId(this.host())) != null;
56 });
57 }
58 /**
59 * Gets the `MatCalendarHarness` that is associated with the trigger.
60 * @param filter Optionally filters which calendar is included.
61 */
62 getCalendar(filter = {}) {
63 return __awaiter(this, void 0, void 0, function* () {
64 return getCalendar(filter, this.host(), this.documentRootLocatorFactory());
65 });
66 }
67}
68MatDatepickerInputHarness.hostSelector = '.mat-datepicker-input';
69//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0ZXBpY2tlci1pbnB1dC1oYXJuZXNzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL21hdGVyaWFsL2RhdGVwaWNrZXIvdGVzdGluZy9kYXRlcGlja2VyLWlucHV0LWhhcm5lc3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HOztBQUVILE9BQU8sRUFBbUIsUUFBUSxFQUFFLE9BQU8sRUFBQyxNQUFNLHNCQUFzQixDQUFDO0FBRXpFLE9BQU8sRUFBQyw2QkFBNkIsRUFBRSxpQkFBaUIsRUFBQyxNQUFNLGlDQUFpQyxDQUFDO0FBRWpHLE9BQU8sRUFFTCxhQUFhLEVBQ2IsYUFBYSxFQUNiLFdBQVcsR0FDWixNQUFNLG1DQUFtQyxDQUFDO0FBRTNDLG1GQUFtRjtBQUNuRixNQUFNLE9BQU8seUJBQTBCLFNBQVEsNkJBQTZCO0lBSTFFOzs7OztPQUtHO0lBQ0gsTUFBTSxDQUFDLElBQUksQ0FBQyxVQUF5QyxFQUFFO1FBRXJELE9BQU8saUJBQWlCLENBQUMseUJBQXlCLEVBQUUsT0FBTyxDQUFDLENBQUM7SUFDL0QsQ0FBQztJQ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