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

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

initial commit

  • Property mode set to 100644
File size: 11.0 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 { HarnessPredicate, } from '@angular/cdk/testing';
10import { MatFormFieldControlHarness } from '@angular/material/form-field/testing/control';
11/** Sets up the filter predicates for a datepicker input harness. */
12export function getInputPredicate(type, options) {
13 return new HarnessPredicate(type, options)
14 .addOption('value', options.value, (harness, value) => {
15 return HarnessPredicate.stringMatches(harness.getValue(), value);
16 })
17 .addOption('placeholder', options.placeholder, (harness, placeholder) => {
18 return HarnessPredicate.stringMatches(harness.getPlaceholder(), placeholder);
19 });
20}
21/** Base class for datepicker input harnesses. */
22export class MatDatepickerInputHarnessBase extends MatFormFieldControlHarness {
23 /** Whether the input is disabled. */
24 isDisabled() {
25 return __awaiter(this, void 0, void 0, function* () {
26 return (yield this.host()).getProperty('disabled');
27 });
28 }
29 /** Whether the input is required. */
30 isRequired() {
31 return __awaiter(this, void 0, void 0, function* () {
32 return (yield this.host()).getProperty('required');
33 });
34 }
35 /** Gets the value of the input. */
36 getValue() {
37 return __awaiter(this, void 0, void 0, function* () {
38 // The "value" property of the native input is always defined.
39 return (yield (yield this.host()).getProperty('value'));
40 });
41 }
42 /**
43 * Sets the value of the input. The value will be set by simulating
44 * keypresses that correspond to the given value.
45 */
46 setValue(newValue) {
47 return __awaiter(this, void 0, void 0, function* () {
48 const inputEl = yield this.host();
49 yield inputEl.clear();
50 // We don't want to send keys for the value if the value is an empty
51 // string in order to clear the value. Sending keys with an empty string
52 // still results in unnecessary focus events.
53 if (newValue) {
54 yield inputEl.sendKeys(newValue);
55 }
56 yield inputEl.dispatchEvent('change');
57 });
58 }
59 /** Gets the placeholder of the input. */
60 getPlaceholder() {
61 return __awaiter(this, void 0, void 0, function* () {
62 return (yield (yield this.host()).getProperty('placeholder'));
63 });
64 }
65 /**
66 * Focuses the input and returns a promise that indicates when the
67 * action is complete.
68 */
69 focus() {
70 return __awaiter(this, void 0, void 0, function* () {
71 return (yield this.host()).focus();
72 });
73 }
74 /**
75 * Blurs the input and returns a promise that indicates when the
76 * action is complete.
77 */
78 blur() {
79 return __awaiter(this, void 0, void 0, function* () {
80 return (yield this.host()).blur();
81 });
82 }
83 /** Whether the input is focused. */
84 isFocused() {
85 return __awaiter(this, void 0, void 0, function* () {
86 return (yield this.host()).isFocused();
87 });
88 }
89 /** Gets the formatted minimum date for the input's value. */
90 getMin() {
91 return __awaiter(this, void 0, void 0, function* () {
92 return (yield this.host()).getAttribute('min');
93 });
94 }
95 /** Gets the formatted maximum date for the input's value. */
96 getMax() {
97 return __awaiter(this, void 0, void 0, function* () {
98 return (yield this.host()).getAttribute('max');
99 });
100 }
101}
102//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0ZXBpY2tlci1pbnB1dC1oYXJuZXNzLWJhc2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvZGF0ZXBpY2tlci90ZXN0aW5nL2RhdGVwaWNrZXItaW5wdXQtaGFybmVzcy1iYXNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRzs7QUFFSCxPQUFPLEVBRUwsZ0JBQWdCLEdBQ2pCLE1BQU0sc0JBQXNCLENBQUM7QUFDOUIsT0FBTyxFQUFDLDBCQUEwQixFQUFDLE1BQU0sOENBQThDLENBQUM7QUFHeEYsb0VBQW9FO0FBQ3BFLE1BQU0sVUFBVSxpQkFBaUIsQ0FDL0IsSUFBb0MsRUFDcEMsT0FBc0M7SUFFdEMsT0F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