1 | {"version":3,"file":"slide-toggle__testing.js","sources":["../../../../../../src/material/slide-toggle/testing/slide-toggle-harness.ts","../../../../../../src/material/slide-toggle/testing/slide-toggle-harness-filters.ts","../../../../../../src/material/slide-toggle/testing/public-api.ts","../../../../../../src/material/slide-toggle/testing/index.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 {ComponentHarness, HarnessPredicate} from '@angular/cdk/testing';\nimport {coerceBooleanProperty} from '@angular/cdk/coercion';\nimport {SlideToggleHarnessFilters} from './slide-toggle-harness-filters';\n\nexport abstract class _MatSlideToggleHarnessBase extends ComponentHarness {\n private _label = this.locatorFor('label');\n protected _input = this.locatorFor('input');\n\n /** Toggle the checked state of the slide-toggle. */\n abstract toggle(): Promise<void>;\n\n /** Whether the slide-toggle is checked. */\n async isChecked(): Promise<boolean> {\n const checked = (await this._input()).getProperty<boolean>('checked');\n return coerceBooleanProperty(await checked);\n }\n\n /** Whether the slide-toggle is disabled. */\n async isDisabled(): Promise<boolean> {\n const disabled = (await this._input()).getAttribute('disabled');\n return coerceBooleanProperty(await disabled);\n }\n\n /** Whether the slide-toggle is required. */\n async isRequired(): Promise<boolean> {\n const required = (await this._input()).getAttribute('required');\n return coerceBooleanProperty(await required);\n }\n\n /** Whether the slide-toggle is valid. */\n async isValid(): Promise<boolean> {\n const invalid = (await this.host()).hasClass('ng-invalid');\n return !(await invalid);\n }\n\n /** Gets the slide-toggle's name. */\n async getName(): Promise<string | null> {\n return (await this._input()).getAttribute('name');\n }\n\n /** Gets the slide-toggle's aria-label. */\n async getAriaLabel(): Promise<string | null> {\n return (await this._input()).getAttribute('aria-label');\n }\n\n /** Gets the slide-toggle's aria-labelledby. */\n async getAriaLabelledby(): Promise<string | null> {\n return (await this._input()).getAttribute('aria-labelledby');\n }\n\n /** Gets the slide-toggle's label text. */\n async getLabelText(): Promise<string> {\n return (await this._label()).text();\n }\n\n /** Focuses the slide-toggle. */\n async focus(): Promise<void> {\n return (await this._input()).focus();\n }\n\n /** Blurs the slide-toggle. */\n async blur(): Promise<void> {\n return (await this._input()).blur();\n }\n\n /** Whether the slide-toggle is focused. */\n async isFocused(): Promise<boolean> {\n return (await this._input()).isFocused();\n }\n\n /**\n * Puts the slide-toggle in a checked state by toggling it if it is currently unchecked, or doing\n * nothing if it is already checked.\n */\n async check(): Promise<void> {\n if (!(await this.isChecked())) {\n await this.toggle();\n }\n }\n\n /**\n * Puts the slide-toggle in an unchecked state by toggling it if it is currently checked, or doing\n * nothing if it is already unchecked.\n */\n async uncheck(): Promise<void> {\n if (await this.isChecked()) {\n await this.toggle();\n }\n }\n}\n\n\n\n/** Harness for interacting with a standard mat-slide-toggle in tests. */\nexport class MatSlideToggleHarness extends _MatSlideToggleHarnessBase {\n /** The selector for the host element of a `MatSlideToggle` instance. */\n static hostSelector = '.mat-slide-toggle';\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a `MatSlideToggleHarness` that meets\n * certain criteria.\n * @param options Options for filtering which slide toggle instances are considered a match.\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with(options: SlideToggleHarnessFilters = {}): HarnessPredicate<MatSlideToggleHarness> {\n return new HarnessPredicate(MatSlideToggleHarness, options)\n .addOption('label', options.label,\n (harness, label) => HarnessPredicate.stringMatches(harness.getLabelText(), label))\n // We want to provide a filter option for \"name\" because the name of the slide-toggle is\n // only set on the underlying input. This means that it's not possible for developers\n // to retrieve the harness of a specific checkbox with name through a CSS selector.\n .addOption('name', options.name, async (harness, name) => await harness.getName() === name);\n }\n\n private _inputContainer = this.locatorFor('.mat-slide-toggle-bar');\n\n /** Toggle the checked state of the slide-toggle. */\n async toggle(): Promise<void> {\n return (await this._inputContainer()).click();\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 {BaseHarnessFilters} from '@angular/cdk/testing';\n\n/** A set of criteria that can be used to filter a list of `MatSlideToggleHarness` instances. */\nexport interface SlideToggleHarnessFilters extends BaseHarnessFilters {\n /** Only find instances whose label matches the given value. */\n label?: string | RegExp;\n /** Only find instances whose name is the given value. */\n name?: string;\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\nexport * from './slide-toggle-harness';\nexport * from './slide-toggle-harness-filters';\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\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAAA;;;;;;;MAYsB,0BAA2B,SAAQ,gBAAgB;IAAzE;;QACU,WAAM,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAChC,WAAM,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;KAmF7C;;IA7EO,SAAS;;YACb,MAAM,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,MAAM,EAAE,EAAE,WAAW,CAAU,SAAS,CAAC,CAAC;YACtE,OAAO,qBAAqB,CAAC,MAAM,OAAO,CAAC,CAAC;SAC7C;KAAA;;IAGK,UAAU;;YACd,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAI,CAAC,MAAM,EAAE,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;YAChE,OAAO,qBAAqB,CAAC,MAAM,QAAQ,CAAC,CAAC;SAC9C;KAAA;;IAGK,UAAU;;YACd,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAI,CAAC,MAAM,EAAE,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;YAChE,OAAO,qBAAqB,CAAC,MAAM,QAAQ,CAAC,CAAC;SAC9C;KAAA;;IAGK,OAAO;;YACX,MAAM,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,EA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