testing.mjs 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. import { ContentContainerComponentHarness, HarnessPredicate, TestKey } from '@angular/cdk/testing';
  2. /** Harness for interacting with a standard MatBottomSheet in tests. */
  3. class MatBottomSheetHarness extends ContentContainerComponentHarness {
  4. // Developers can provide a custom component or template for the
  5. // bottom sheet. The canonical parent is the ".mat-bottom-sheet-container".
  6. static hostSelector = '.mat-bottom-sheet-container:not([mat-exit])';
  7. /**
  8. * Gets a `HarnessPredicate` that can be used to search for a bottom sheet with
  9. * specific attributes.
  10. * @param options Options for narrowing the search.
  11. * @return a `HarnessPredicate` configured with the given options.
  12. */
  13. static with(options = {}) {
  14. return new HarnessPredicate(MatBottomSheetHarness, options);
  15. }
  16. /** Gets the value of the bottom sheet's "aria-label" attribute. */
  17. async getAriaLabel() {
  18. return (await this.host()).getAttribute('aria-label');
  19. }
  20. /**
  21. * Dismisses the bottom sheet by pressing escape. Note that this method cannot
  22. * be used if "disableClose" has been set to true via the config.
  23. */
  24. async dismiss() {
  25. await (await this.host()).sendKeys(TestKey.ESCAPE);
  26. }
  27. }
  28. export { MatBottomSheetHarness };
  29. //# sourceMappingURL=testing.mjs.map