index.d.ts 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 `MatCheckboxHarness` instances. */
  4. interface CheckboxHarnessFilters extends BaseHarnessFilters {
  5. /** Only find instances whose label matches the given value. */
  6. label?: string | RegExp;
  7. /** Only find instances whose name attribute is the given value. */
  8. name?: string;
  9. /** Only find instances with the given checked value. */
  10. checked?: boolean;
  11. /** Only find instances which match the given disabled state. */
  12. disabled?: boolean;
  13. }
  14. /** Harness for interacting with a mat-checkbox in tests. */
  15. declare class MatCheckboxHarness extends ComponentHarness {
  16. static hostSelector: string;
  17. _input: () => Promise<_angular_cdk_testing.TestElement>;
  18. private _label;
  19. private _inputContainer;
  20. /**
  21. * Gets a `HarnessPredicate` that can be used to search for a checkbox with specific attributes.
  22. * @param options Options for narrowing the search:
  23. * - `selector` finds a checkbox whose host element matches the given selector.
  24. * - `label` finds a checkbox with specific label text.
  25. * - `name` finds a checkbox with specific name.
  26. * @return a `HarnessPredicate` configured with the given options.
  27. */
  28. static with<T extends MatCheckboxHarness>(this: ComponentHarnessConstructor<T>, options?: CheckboxHarnessFilters): HarnessPredicate<T>;
  29. /** Whether the checkbox is checked. */
  30. isChecked(): Promise<boolean>;
  31. /** Whether the checkbox is in an indeterminate state. */
  32. isIndeterminate(): Promise<boolean>;
  33. /** Whether the checkbox is disabled. */
  34. isDisabled(): Promise<boolean>;
  35. /** Whether the checkbox is required. */
  36. isRequired(): Promise<boolean>;
  37. /** Whether the checkbox is valid. */
  38. isValid(): Promise<boolean>;
  39. /** Gets the checkbox's name. */
  40. getName(): Promise<string | null>;
  41. /** Gets the checkbox's value. */
  42. getValue(): Promise<string | null>;
  43. /** Gets the checkbox's aria-label. */
  44. getAriaLabel(): Promise<string | null>;
  45. /** Gets the checkbox's aria-labelledby. */
  46. getAriaLabelledby(): Promise<string | null>;
  47. /** Gets the checkbox's label text. */
  48. getLabelText(): Promise<string>;
  49. /** Focuses the checkbox. */
  50. focus(): Promise<void>;
  51. /** Blurs the checkbox. */
  52. blur(): Promise<void>;
  53. /** Whether the checkbox is focused. */
  54. isFocused(): Promise<boolean>;
  55. /**
  56. * Toggles the checked state of the checkbox.
  57. *
  58. * Note: This attempts to toggle the checkbox as a user would, by clicking it. Therefore if you
  59. * are using `MAT_CHECKBOX_DEFAULT_OPTIONS` to change the behavior on click, calling this method
  60. * might not have the expected result.
  61. */
  62. toggle(): Promise<void>;
  63. /**
  64. * Puts the checkbox in a checked state by toggling it if it is currently unchecked, or doing
  65. * nothing if it is already checked.
  66. *
  67. * Note: This attempts to check the checkbox as a user would, by clicking it. Therefore if you
  68. * are using `MAT_CHECKBOX_DEFAULT_OPTIONS` to change the behavior on click, calling this method
  69. * might not have the expected result.
  70. */
  71. check(): Promise<void>;
  72. /**
  73. * Puts the checkbox in an unchecked state by toggling it if it is currently checked, or doing
  74. * nothing if it is already unchecked.
  75. *
  76. * Note: This attempts to uncheck the checkbox as a user would, by clicking it. Therefore if you
  77. * are using `MAT_CHECKBOX_DEFAULT_OPTIONS` to change the behavior on click, calling this method
  78. * might not have the expected result.
  79. */
  80. uncheck(): Promise<void>;
  81. }
  82. export { MatCheckboxHarness };
  83. export type { CheckboxHarnessFilters };