source: trip-planner-front/node_modules/@angular/material/esm2015/chips/testing/chip-input-harness.js@ 188ee53

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

initial commit

  • Property mode set to 100644
File size: 10.6 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { __awaiter } from "tslib";
9import { HarnessPredicate, ComponentHarness } from '@angular/cdk/testing';
10/** Harness for interacting with a standard Material chip inputs in tests. */
11export class MatChipInputHarness extends ComponentHarness {
12 /**
13 * Gets a `HarnessPredicate` that can be used to search for a `MatChipInputHarness` that meets
14 * certain criteria.
15 * @param options Options for filtering which input instances are considered a match.
16 * @return a `HarnessPredicate` configured with the given options.
17 */
18 static with(options = {}) {
19 return new HarnessPredicate(MatChipInputHarness, options)
20 .addOption('value', options.value, (harness, value) => __awaiter(this, void 0, void 0, function* () {
21 return (yield harness.getValue()) === value;
22 }))
23 .addOption('placeholder', options.placeholder, (harness, placeholder) => __awaiter(this, void 0, void 0, function* () {
24 return (yield harness.getPlaceholder()) === placeholder;
25 }));
26 }
27 /** Whether the input is disabled. */
28 isDisabled() {
29 return __awaiter(this, void 0, void 0, function* () {
30 return (yield this.host()).getProperty('disabled');
31 });
32 }
33 /** Whether the input is required. */
34 isRequired() {
35 return __awaiter(this, void 0, void 0, function* () {
36 return (yield this.host()).getProperty('required');
37 });
38 }
39 /** Gets the value of the input. */
40 getValue() {
41 return __awaiter(this, void 0, void 0, function* () {
42 // The "value" property of the native input is never undefined.
43 return (yield (yield this.host()).getProperty('value'));
44 });
45 }
46 /** Gets the placeholder of the input. */
47 getPlaceholder() {
48 return __awaiter(this, void 0, void 0, function* () {
49 return (yield (yield this.host()).getProperty('placeholder'));
50 });
51 }
52 /**
53 * Focuses the input and returns a promise that indicates when the
54 * action is complete.
55 */
56 focus() {
57 return __awaiter(this, void 0, void 0, function* () {
58 return (yield this.host()).focus();
59 });
60 }
61 /**
62 * Blurs the input and returns a promise that indicates when the
63 * action is complete.
64 */
65 blur() {
66 return __awaiter(this, void 0, void 0, function* () {
67 return (yield this.host()).blur();
68 });
69 }
70 /** Whether the input is focused. */
71 isFocused() {
72 return __awaiter(this, void 0, void 0, function* () {
73 return (yield this.host()).isFocused();
74 });
75 }
76 /**
77 * Sets the value of the input. The value will be set by simulating
78 * keypresses that correspond to the given value.
79 */
80 setValue(newValue) {
81 return __awaiter(this, void 0, void 0, function* () {
82 const inputEl = yield this.host();
83 yield inputEl.clear();
84 // We don't want to send keys for the value if the value is an empty
85 // string in order to clear the value. Sending keys with an empty string
86 // still results in unnecessary focus events.
87 if (newValue) {
88 yield inputEl.sendKeys(newValue);
89 }
90 });
91 }
92 /** Sends a chip separator key to the input element. */
93 sendSeparatorKey(key) {
94 return __awaiter(this, void 0, void 0, function* () {
95 const inputEl = yield this.host();
96 return inputEl.sendKeys(key);
97 });
98 }
99}
100MatChipInputHarness.hostSelector = '.mat-chip-input';
101//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hpcC1pbnB1dC1oYXJuZXNzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL21hdGVyaWFsL2NoaXBzL3Rlc3RpbmcvY2hpcC1pbnB1dC1oYXJuZXNzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRzs7QUFFSCxPQUFPLEVBQUMsZ0JBQWdCLEVBQUUsZ0JBQWdCLEVBQVUsTUFBTSxzQkFBc0IsQ0FBQztBQUdqRiw2RUFBNkU7QUFDN0UsTUFBTSxPQUFPLG1CQUFvQixTQUFRLGdCQUFnQjtJQUd2RDs7Ozs7T0FLRztJQUNILE1BQU0sQ0FBQyxJQUFJLENBQUMsVUFBbUMsRUFBRTtRQUMvQyxPQUFPLElBQUksZ0JBQWdCL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