/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { ComponentHarness, HarnessPredicate, } from '@angular/cdk/testing'; import { coerceBooleanProperty } from '@angular/cdk/coercion'; export class _MatSlideToggleHarnessBase extends ComponentHarness { constructor() { super(...arguments); this._label = this.locatorFor('label'); } /** Whether the slide-toggle is disabled. */ async isDisabled() { const disabled = (await this._nativeElement()).getAttribute('disabled'); return coerceBooleanProperty(await disabled); } /** Whether the slide-toggle is required. */ async isRequired() { const required = (await this._nativeElement()).getAttribute('required'); return coerceBooleanProperty(await required); } /** Whether the slide-toggle is valid. */ async isValid() { const invalid = (await this.host()).hasClass('ng-invalid'); return !(await invalid); } /** Gets the slide-toggle's name. */ async getName() { return (await this._nativeElement()).getAttribute('name'); } /** Gets the slide-toggle's aria-label. */ async getAriaLabel() { return (await this._nativeElement()).getAttribute('aria-label'); } /** Gets the slide-toggle's aria-labelledby. */ async getAriaLabelledby() { return (await this._nativeElement()).getAttribute('aria-labelledby'); } /** Gets the slide-toggle's label text. */ async getLabelText() { return (await this._label()).text(); } /** Focuses the slide-toggle. */ async focus() { return (await this._nativeElement()).focus(); } /** Blurs the slide-toggle. */ async blur() { return (await this._nativeElement()).blur(); } /** Whether the slide-toggle is focused. */ async isFocused() { return (await this._nativeElement()).isFocused(); } /** * Puts the slide-toggle in a checked state by toggling it if it is currently unchecked, or doing * nothing if it is already checked. */ async check() { if (!(await this.isChecked())) { await this.toggle(); } } /** * Puts the slide-toggle in an unchecked state by toggling it if it is currently checked, or doing * nothing if it is already unchecked. */ async uncheck() { if (await this.isChecked()) { await this.toggle(); } } } /** Harness for interacting with a MDC-based mat-slide-toggle in tests. */ export class MatSlideToggleHarness extends _MatSlideToggleHarnessBase { constructor() { super(...arguments); this._nativeElement = this.locatorFor('button'); } static { this.hostSelector = '.mat-mdc-slide-toggle'; } /** * Gets a `HarnessPredicate` that can be used to search for a slide-toggle w/ specific attributes. * @param options Options for narrowing the search: * - `selector` finds a slide-toggle whose host element matches the given selector. * - `label` finds a slide-toggle with specific label text. * @return a `HarnessPredicate` configured with the given options. */ static with(options = {}) { return (new HarnessPredicate(this, options) .addOption('label', options.label, (harness, label) => HarnessPredicate.stringMatches(harness.getLabelText(), label)) // We want to provide a filter option for "name" because the name of the slide-toggle is // only set on the underlying input. This means that it's not possible for developers // to retrieve the harness of a specific checkbox with name through a CSS selector. .addOption('name', options.name, async (harness, name) => (await harness.getName()) === name) .addOption('checked', options.checked, async (harness, checked) => (await harness.isChecked()) == checked) .addOption('disabled', options.disabled, async (harness, disabled) => (await harness.isDisabled()) == disabled)); } async toggle() { return (await this._nativeElement()).click(); } async isRequired() { const ariaRequired = await (await this._nativeElement()).getAttribute('aria-required'); return ariaRequired === 'true'; } async isChecked() { const checked = (await this._nativeElement()).getAttribute('aria-checked'); return coerceBooleanProperty(await checked); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2xpZGUtdG9nZ2xlLWhhcm5lc3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvc2xpZGUtdG9nZ2xlL3Rlc3Rpbmcvc2xpZGUtdG9nZ2xlLWhhcm5lc3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUVMLGdCQUFnQixFQUVoQixnQkFBZ0IsR0FFakIsTUFBTSxzQkFBc0IsQ0FBQztBQUM5QixPQUFPLEVBQUMscUJBQXFCLEVBQUMsTUFBTSx1QkFBdUIsQ0FBQztBQUc1RCxNQUFNLE9BQWdCLDBCQUEyQixTQUFRLGdCQUFnQjtJQUF6RTs7UUFDVSxXQUFNLEdBQUcsSUFBSSxDQUFDLFVBQVUsQ0FBQyxPQUFPLENBQUMsQ0FBQztJQWlGNUMsQ0FBQztJQXhFQyw0Q0FBNE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