/** * @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 { _MatSnackBarHarnessBase } from '@angular/material/snack-bar/testing'; /** * Harness for interacting with a standard mat-snack-bar in tests. * @deprecated Use `MatSnackBarHarness` from `@angular/material/snack-bar/testing` instead. See https://material.angular.io/guide/mdc-migration for information about migrating. * @breaking-change 17.0.0 */ export class MatLegacySnackBarHarness extends _MatSnackBarHarnessBase { constructor() { super(...arguments); this._messageSelector = '.mat-simple-snackbar > span'; this._actionButtonSelector = '.mat-simple-snackbar-action > button'; } // Developers can provide a custom component or template for the snackbar. The canonical snack-bar // parent is the "MatSnackBarContainer". We use `:not([mat-exit])` to exclude snack bars that // are in the process of being dismissed, because the element only gets removed after the // animation is finished and since it runs outside of Angular, we don't have a way of being // notified when it's done. /** The selector for the host element of a `MatSnackBar` instance. */ static { this.hostSelector = '.mat-snack-bar-container'; } /** * Gets a `HarnessPredicate` that can be used to search for a snack bar with specific attributes. * @param options Options for filtering which snack bar instances are considered a match. * @return a `HarnessPredicate` configured with the given options. */ static with(options = {}) { return new HarnessPredicate(MatLegacySnackBarHarness, options); } async _assertContentAnnotated() { if (!(await this._isSimpleSnackBar())) { throw Error('Method cannot be used for snack-bar with custom content.'); } } /** Whether the snack-bar is using the default content template. */ async _isSimpleSnackBar() { return (await this.locatorForOptional('.mat-simple-snackbar')()) !== null; } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic25hY2stYmFyLWhhcm5lc3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvbGVnYWN5LXNuYWNrLWJhci90ZXN0aW5nL3NuYWNrLWJhci1oYXJuZXNzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUNILE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