/** * @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 { HarnessPredicate } from '@angular/cdk/testing'; import { coerceBooleanProperty } from '@angular/cdk/coercion'; import { DatepickerTriggerHarnessBase } from './datepicker-trigger-harness-base'; /** Harness for interacting with a standard Material datepicker toggle in tests. */ export class MatDatepickerToggleHarness extends DatepickerTriggerHarnessBase { constructor() { super(...arguments); /** The clickable button inside the toggle. */ this._button = this.locatorFor('button'); } static { this.hostSelector = '.mat-datepicker-toggle'; } /** * Gets a `HarnessPredicate` that can be used to search for a `MatDatepickerToggleHarness` that * meets certain criteria. * @param options Options for filtering which datepicker toggle instances are considered a match. * @return a `HarnessPredicate` configured with the given options. */ static with(options = {}) { return new HarnessPredicate(MatDatepickerToggleHarness, options); } /** Gets whether the calendar associated with the toggle is open. */ async isCalendarOpen() { return (await this.host()).hasClass('mat-datepicker-toggle-active'); } /** Whether the toggle is disabled. */ async isDisabled() { const button = await this._button(); return coerceBooleanProperty(await button.getAttribute('disabled')); } async _openCalendar() { return (await this._button()).click(); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0ZXBpY2tlci10b2dnbGUtaGFybmVzcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9kYXRlcGlja2VyL3Rlc3RpbmcvZGF0ZXBpY2tlci10b2dnbGUtaGFybmVzcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQUMsZ0JBQWdCLEVBQUMsTUFBTSxzQkFBc0IsQ0FBQztBQUN0RCxPQUFPLEVBQUMscUJBQXFCLEVBQUMsTUFBTSx1QkFBdUIsQ0FBQztBQUU1RCxPQUFPLEVBQUMsNEJBQTRCLEVBQUMsTUFBTSxtQ0FBbUMsQ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