source: trip-planner-front/node_modules/@angular/material/esm2015/slider/testing/slider-harness.js@ 8d391a1

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

initial commit

  • Property mode set to 100644
File size: 17.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 { ComponentHarness, HarnessPredicate, parallel } from '@angular/cdk/testing';
10import { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';
11/** Harness for interacting with a standard mat-slider in tests. */
12export class MatSliderHarness extends ComponentHarness {
13 constructor() {
14 super(...arguments);
15 this._textLabel = this.locatorFor('.mat-slider-thumb-label-text');
16 this._wrapper = this.locatorFor('.mat-slider-wrapper');
17 }
18 /**
19 * Gets a `HarnessPredicate` that can be used to search for a `MatSliderHarness` that meets
20 * certain criteria.
21 * @param options Options for filtering which slider instances are considered a match.
22 * @return a `HarnessPredicate` configured with the given options.
23 */
24 static with(options = {}) {
25 return new HarnessPredicate(MatSliderHarness, options);
26 }
27 /** Gets the slider's id. */
28 getId() {
29 return __awaiter(this, void 0, void 0, function* () {
30 const id = yield (yield this.host()).getAttribute('id');
31 // In case no id has been specified, the "id" property always returns
32 // an empty string. To make this method more explicit, we return null.
33 return id !== '' ? id : null;
34 });
35 }
36 /**
37 * Gets the current display value of the slider. Returns a null promise if the thumb label is
38 * disabled.
39 */
40 getDisplayValue() {
41 return __awaiter(this, void 0, void 0, function* () {
42 const [host, textLabel] = yield parallel(() => [this.host(), this._textLabel()]);
43 if (yield host.hasClass('mat-slider-thumb-label-showing')) {
44 return textLabel.text();
45 }
46 return null;
47 });
48 }
49 /** Gets the current percentage value of the slider. */
50 getPercentage() {
51 return __awaiter(this, void 0, void 0, function* () {
52 return this._calculatePercentage(yield this.getValue());
53 });
54 }
55 /** Gets the current value of the slider. */
56 getValue() {
57 return __awaiter(this, void 0, void 0, function* () {
58 return coerceNumberProperty(yield (yield this.host()).getAttribute('aria-valuenow'));
59 });
60 }
61 /** Gets the maximum value of the slider. */
62 getMaxValue() {
63 return __awaiter(this, void 0, void 0, function* () {
64 return coerceNumberProperty(yield (yield this.host()).getAttribute('aria-valuemax'));
65 });
66 }
67 /** Gets the minimum value of the slider. */
68 getMinValue() {
69 return __awaiter(this, void 0, void 0, function* () {
70 return coerceNumberProperty(yield (yield this.host()).getAttribute('aria-valuemin'));
71 });
72 }
73 /** Whether the slider is disabled. */
74 isDisabled() {
75 return __awaiter(this, void 0, void 0, function* () {
76 const disabled = (yield this.host()).getAttribute('aria-disabled');
77 return coerceBooleanProperty(yield disabled);
78 });
79 }
80 /** Gets the orientation of the slider. */
81 getOrientation() {
82 return __awaiter(this, void 0, void 0, function* () {
83 // "aria-orientation" will always be set to either "horizontal" or "vertical".
84 return (yield this.host()).getAttribute('aria-orientation');
85 });
86 }
87 /**
88 * Sets the value of the slider by clicking on the slider track.
89 *
90 * Note that in rare cases the value cannot be set to the exact specified value. This
91 * can happen if not every value of the slider maps to a single pixel that could be
92 * clicked using mouse interaction. In such cases consider using the keyboard to
93 * select the given value or expand the slider's size for a better user experience.
94 */
95 setValue(value) {
96 return __awaiter(this, void 0, void 0, function* () {
97 const [sliderEl, wrapperEl, orientation] = yield parallel(() => [this.host(), this._wrapper(), this.getOrientation()]);
98 let percentage = yield this._calculatePercentage(value);
99 const { height, width } = yield wrapperEl.getDimensions();
100 const isVertical = orientation === 'vertical';
101 // In case the slider is inverted in LTR mode or not inverted in RTL mode,
102 // we need to invert the percentage so that the proper value is set.
103 if (yield sliderEl.hasClass('mat-slider-invert-mouse-coords')) {
104 percentage = 1 - percentage;
105 }
106 // We need to round the new coordinates because creating fake DOM
107 // events will cause the coordinates to be rounded down.
108 const relativeX = isVertical ? 0 : Math.round(width * percentage);
109 const relativeY = isVertical ? Math.round(height * percentage) : 0;
110 yield wrapperEl.click(relativeX, relativeY);
111 });
112 }
113 /** Focuses the slider. */
114 focus() {
115 return __awaiter(this, void 0, void 0, function* () {
116 return (yield this.host()).focus();
117 });
118 }
119 /** Blurs the slider. */
120 blur() {
121 return __awaiter(this, void 0, void 0, function* () {
122 return (yield this.host()).blur();
123 });
124 }
125 /** Whether the slider is focused. */
126 isFocused() {
127 return __awaiter(this, void 0, void 0, function* () {
128 return (yield this.host()).isFocused();
129 });
130 }
131 /** Calculates the percentage of the given value. */
132 _calculatePercentage(value) {
133 return __awaiter(this, void 0, void 0, function* () {
134 const [min, max] = yield parallel(() => [this.getMinValue(), this.getMaxValue()]);
135 return (value - min) / (max - min);
136 });
137 }
138}
139/** The selector for the host element of a `MatSlider` instance. */
140MatSliderHarness.hostSelector = '.mat-slider';
141//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2xpZGVyLWhhcm5lc3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvc2xpZGVyL3Rlc3Rpbmcvc2xpZGVyLWhhcm5lc3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HOztBQUVILE9BQU8sRUFBQyxnQkFBZ0IsRUFBRSxnQkFBZ0IsRUFBRSxRQUFRLEVBQUMsTUFBTSxzQkFBc0IsQ0FBQztBQUNsRixPQUFPLEVBQUMscUJBQXFCLEVBQUUsb0JBQW9CLEVBQUMsTUFBTSx1QkFBdUIsQ0FBQztBQUdsRixtRUFBbUU7QUFDbkUsTUFBTSxPQUFPLGdCQUFpQixTQUFRLGdCQUFnQjtJQUF0RDs7UUFjVSxlQUFVLEdBQUcsSUFBSSxDQUFDLFVBQVUsQ0FBQyw4QkFBOEIsQ0FBQyxDQUFDO1FBQzdELGFBQVEsR0FBRyxJQUFJLENBQUMsVUFBVSxDQUFDLHFCQUFxQixDQUFDLENBQUM7SUF1RzVELENBQUM7SUFsSEM7Ozs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