index.d.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import * as _angular_cdk_testing from '@angular/cdk/testing';
  2. import { BaseHarnessFilters, ComponentHarness, ComponentHarnessConstructor, HarnessPredicate } from '@angular/cdk/testing';
  3. /** A set of criteria that can be used to filter a list of `MatSlideToggleHarness` instances. */
  4. interface SlideToggleHarnessFilters extends BaseHarnessFilters {
  5. /** Only find instances whose label matches the given value. */
  6. label?: string | RegExp;
  7. /** Only find instances whose name is the given value. */
  8. name?: string;
  9. /** Only find instances with the given checked value. */
  10. checked?: boolean;
  11. /** Only find instances where the disabled state matches the given value. */
  12. disabled?: boolean;
  13. }
  14. /** Harness for interacting with a mat-slide-toggle in tests. */
  15. declare class MatSlideToggleHarness extends ComponentHarness {
  16. private _label;
  17. _nativeElement: () => Promise<_angular_cdk_testing.TestElement>;
  18. static hostSelector: string;
  19. /**
  20. * Gets a `HarnessPredicate` that can be used to search for a slide-toggle w/ specific attributes.
  21. * @param options Options for narrowing the search:
  22. * - `selector` finds a slide-toggle whose host element matches the given selector.
  23. * - `label` finds a slide-toggle with specific label text.
  24. * @return a `HarnessPredicate` configured with the given options.
  25. */
  26. static with<T extends MatSlideToggleHarness>(this: ComponentHarnessConstructor<T>, options?: SlideToggleHarnessFilters): HarnessPredicate<T>;
  27. /** Toggle the checked state of the slide-toggle. */
  28. toggle(): Promise<void>;
  29. /** Whether the slide-toggle is checked. */
  30. isChecked(): Promise<boolean>;
  31. /** Whether the slide-toggle is disabled. */
  32. isDisabled(): Promise<boolean>;
  33. /** Whether the slide-toggle is required. */
  34. isRequired(): Promise<boolean>;
  35. /** Whether the slide-toggle is valid. */
  36. isValid(): Promise<boolean>;
  37. /** Gets the slide-toggle's name. */
  38. getName(): Promise<string | null>;
  39. /** Gets the slide-toggle's aria-label. */
  40. getAriaLabel(): Promise<string | null>;
  41. /** Gets the slide-toggle's aria-labelledby. */
  42. getAriaLabelledby(): Promise<string | null>;
  43. /** Gets the slide-toggle's label text. */
  44. getLabelText(): Promise<string>;
  45. /** Focuses the slide-toggle. */
  46. focus(): Promise<void>;
  47. /** Blurs the slide-toggle. */
  48. blur(): Promise<void>;
  49. /** Whether the slide-toggle is focused. */
  50. isFocused(): Promise<boolean>;
  51. /**
  52. * Puts the slide-toggle in a checked state by toggling it if it is currently unchecked, or doing
  53. * nothing if it is already checked.
  54. */
  55. check(): Promise<void>;
  56. /**
  57. * Puts the slide-toggle in an unchecked state by toggling it if it is currently checked, or doing
  58. * nothing if it is already unchecked.
  59. */
  60. uncheck(): Promise<void>;
  61. }
  62. export { MatSlideToggleHarness };
  63. export type { SlideToggleHarnessFilters };