{"version":3,"file":"testing.mjs","sources":["../../../../../../../src/material/slider/testing/slider-thumb-harness.ts","../../../../../../../src/material/slider/testing/slider-harness.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {coerceNumberProperty} from '@angular/cdk/coercion';\nimport {\n ComponentHarness,\n ComponentHarnessConstructor,\n HarnessPredicate,\n parallel,\n} from '@angular/cdk/testing';\nimport {SliderThumbHarnessFilters, ThumbPosition} from './slider-harness-filters';\n\n/** Harness for interacting with a thumb inside of a Material slider in tests. */\nexport class MatSliderThumbHarness extends ComponentHarness {\n static hostSelector =\n 'input[matSliderThumb], input[matSliderStartThumb], input[matSliderEndThumb]';\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a slider thumb with specific attributes.\n * @param options Options for filtering which thumb instances are considered a match.\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with(\n this: ComponentHarnessConstructor,\n options: SliderThumbHarnessFilters = {},\n ): HarnessPredicate {\n return new HarnessPredicate(this, options).addOption(\n 'position',\n options.position,\n async (harness, value) => {\n return (await harness.getPosition()) === value;\n },\n );\n }\n\n /** Gets the position of the thumb inside the slider. */\n async getPosition(): Promise {\n // Meant to mimic MDC's logic where `matSliderThumb` is treated as END.\n const isStart = (await (await this.host()).getAttribute('matSliderStartThumb')) != null;\n return isStart ? ThumbPosition.START : ThumbPosition.END;\n }\n\n /** Gets the value of the thumb. */\n async getValue(): Promise {\n return await (await this.host()).getProperty('valueAsNumber');\n }\n\n /** Sets the value of the thumb. */\n async setValue(newValue: number): Promise {\n const input = await this.host();\n\n // Since this is a range input, we can't simulate the user interacting with it so we set the\n // value directly and dispatch a couple of fake events to ensure that everything fires.\n await input.setInputValue(newValue + '');\n await input.dispatchEvent('input');\n await input.dispatchEvent('change');\n }\n\n /** Gets the current percentage value of the slider. */\n async getPercentage(): Promise {\n const [value, min, max] = await parallel(() => [\n this.getValue(),\n this.getMinValue(),\n this.getMaxValue(),\n ]);\n\n return (value - min) / (max - min);\n }\n\n /** Gets the maximum value of the thumb. */\n async getMaxValue(): Promise {\n return coerceNumberProperty(await (await this.host()).getProperty('max'));\n }\n\n /** Gets the minimum value of the thumb. */\n async getMinValue(): Promise {\n return coerceNumberProperty(await (await this.host()).getProperty('min'));\n }\n\n /** Gets the text representation of the slider's value. */\n async getDisplayValue(): Promise {\n return (await (await this.host()).getAttribute('aria-valuetext')) || '';\n }\n\n /** Whether the thumb is disabled. */\n async isDisabled(): Promise {\n return (await this.host()).getProperty('disabled');\n }\n\n /** Gets the name of the thumb. */\n async getName(): Promise {\n return await (await this.host()).getProperty('name');\n }\n\n /** Gets the id of the thumb. */\n async getId(): Promise {\n return await (await this.host()).getProperty('id');\n }\n\n /**\n * Focuses the thumb and returns a promise that indicates when the\n * action is complete.\n */\n async focus(): Promise {\n return (await this.host()).focus();\n }\n\n /**\n * Blurs the thumb and returns a promise that indicates when the\n * action is complete.\n */\n async blur(): Promise {\n return (await this.host()).blur();\n }\n\n /** Whether the thumb is focused. */\n async isFocused(): Promise {\n return (await this.host()).isFocused();\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {\n ComponentHarness,\n ComponentHarnessConstructor,\n HarnessPredicate,\n} from '@angular/cdk/testing';\nimport {coerceNumberProperty} from '@angular/cdk/coercion';\nimport {SliderHarnessFilters, ThumbPosition} from './slider-harness-filters';\nimport {MatSliderThumbHarness} from './slider-thumb-harness';\n\n/** Harness for interacting with a MDC mat-slider in tests. */\nexport class MatSliderHarness extends ComponentHarness {\n static hostSelector = '.mat-mdc-slider';\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a slider with specific attributes.\n * @param options Options for filtering which input instances are considered a match.\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with(\n this: ComponentHarnessConstructor,\n options: SliderHarnessFilters = {},\n ): HarnessPredicate {\n return new HarnessPredicate(this, options)\n .addOption('isRange', options.isRange, async (harness, value) => {\n return (await harness.isRange()) === value;\n })\n .addOption('disabled', options.disabled, async (harness, disabled) => {\n return (await harness.isDisabled()) === disabled;\n });\n }\n\n /** Gets the start thumb of the slider (only applicable for range sliders). */\n async getStartThumb(): Promise {\n if (!(await this.isRange())) {\n throw Error(\n '`getStartThumb` is only applicable for range sliders. ' +\n 'Did you mean to use `getEndThumb`?',\n );\n }\n return this.locatorFor(MatSliderThumbHarness.with({position: ThumbPosition.START}))();\n }\n\n /** Gets the thumb (for single point sliders), or the end thumb (for range sliders). */\n async getEndThumb(): Promise {\n return this.locatorFor(MatSliderThumbHarness.with({position: ThumbPosition.END}))();\n }\n\n /** Gets whether the slider is a range slider. */\n async isRange(): Promise {\n return await (await this.host()).hasClass('mdc-slider--range');\n }\n\n /** Gets whether the slider is disabled. */\n async isDisabled(): Promise {\n return await (await this.host()).hasClass('mdc-slider--disabled');\n }\n\n /** Gets the value step increments of the slider. */\n async getStep(): Promise {\n // The same step value is forwarded to both thumbs.\n const startHost = await (await this.getEndThumb()).host();\n return coerceNumberProperty(await startHost.getProperty('step'));\n }\n\n /** Gets the maximum value of the slider. */\n async getMaxValue(): Promise {\n return (await this.getEndThumb()).getMaxValue();\n }\n\n /** Gets the minimum value of the slider. */\n async getMinValue(): Promise {\n const startThumb = (await this.isRange())\n ? await this.getStartThumb()\n : await this.getEndThumb();\n return startThumb.getMinValue();\n }\n}\n"],"names":[],"mappings":";;;AAiBA;AACM,MAAO,qBAAsB,SAAQ,gBAAgB,CAAA;aAClD,IAAY,CAAA,YAAA,GACjB,6EAA6E,CAAC,EAAA;AAEhF;;;;AAIG;AACH,IAAA,OAAO,IAAI,CAET,OAAA,GAAqC,EAAE,EAAA;QAEvC,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,SAAS,CAClD,UAAU,EACV,OAAO,CAAC,QAAQ,EAChB,OAA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