index.d.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { BaseHarnessFilters, ContentContainerComponentHarness, ComponentHarnessConstructor, HarnessPredicate } from '@angular/cdk/testing';
  2. /** Possible button appearances. */
  3. type ButtonVariant = 'basic' | 'raised' | 'flat' | 'icon' | 'stroked' | 'fab' | 'mini-fab';
  4. /** A set of criteria that can be used to filter a list of button harness instances. */
  5. interface ButtonHarnessFilters extends BaseHarnessFilters {
  6. /** Only find instances whose text matches the given value. */
  7. text?: string | RegExp;
  8. /** Only find instances with a variant. */
  9. variant?: ButtonVariant;
  10. /** Only find instances which match the given disabled state. */
  11. disabled?: boolean;
  12. }
  13. /** Harness for interacting with a mat-button in tests. */
  14. declare class MatButtonHarness extends ContentContainerComponentHarness {
  15. static hostSelector: string;
  16. /**
  17. * Gets a `HarnessPredicate` that can be used to search for a button with specific attributes.
  18. * @param options Options for narrowing the search:
  19. * - `selector` finds a button whose host element matches the given selector.
  20. * - `text` finds a button with specific text content.
  21. * - `variant` finds buttons matching a specific variant.
  22. * @return a `HarnessPredicate` configured with the given options.
  23. */
  24. static with<T extends MatButtonHarness>(this: ComponentHarnessConstructor<T>, options?: ButtonHarnessFilters): HarnessPredicate<T>;
  25. /**
  26. * Clicks the button at the given position relative to its top-left.
  27. * @param relativeX The relative x position of the click.
  28. * @param relativeY The relative y position of the click.
  29. */
  30. click(relativeX: number, relativeY: number): Promise<void>;
  31. /** Clicks the button at its center. */
  32. click(location: 'center'): Promise<void>;
  33. /** Clicks the button. */
  34. click(): Promise<void>;
  35. /** Gets a boolean promise indicating if the button is disabled. */
  36. isDisabled(): Promise<boolean>;
  37. /** Gets a promise for the button's label text. */
  38. getText(): Promise<string>;
  39. /** Focuses the button and returns a void promise that indicates when the action is complete. */
  40. focus(): Promise<void>;
  41. /** Blurs the button and returns a void promise that indicates when the action is complete. */
  42. blur(): Promise<void>;
  43. /** Whether the button is focused. */
  44. isFocused(): Promise<boolean>;
  45. /** Gets the variant of the button. */
  46. getVariant(): Promise<ButtonVariant>;
  47. }
  48. export { MatButtonHarness };
  49. export type { ButtonHarnessFilters, ButtonVariant };