index.d.ts 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import { BaseHarnessFilters, ContentContainerComponentHarness, HarnessPredicate, HarnessLoader, ComponentHarness } from '@angular/cdk/testing';
  2. /** Possible orientations for a stepper. */
  3. declare enum StepperOrientation {
  4. HORIZONTAL = 0,
  5. VERTICAL = 1
  6. }
  7. /** A set of criteria that can be used to filter a list of `MatStepHarness` instances. */
  8. interface StepHarnessFilters extends BaseHarnessFilters {
  9. /** Only find instances whose label matches the given value. */
  10. label?: string | RegExp;
  11. /** Only find steps with the given selected state. */
  12. selected?: boolean;
  13. /** Only find completed steps. */
  14. completed?: boolean;
  15. /** Only find steps that have errors. */
  16. invalid?: boolean;
  17. }
  18. /** A set of criteria that can be used to filter a list of `MatStepperHarness` instances. */
  19. interface StepperHarnessFilters extends BaseHarnessFilters {
  20. /** Only find instances whose orientation matches the given value. */
  21. orientation?: StepperOrientation;
  22. }
  23. /**
  24. * A set of criteria that can be used to filter a list of
  25. * `MatStepperNextHarness` and `MatStepperPreviousHarness` instances.
  26. */
  27. interface StepperButtonHarnessFilters extends BaseHarnessFilters {
  28. /** Only find instances whose text matches the given value. */
  29. text?: string | RegExp;
  30. }
  31. /** Harness for interacting with a standard Angular Material step in tests. */
  32. declare class MatStepHarness extends ContentContainerComponentHarness<string> {
  33. /** The selector for the host element of a `MatStep` instance. */
  34. static hostSelector: string;
  35. /**
  36. * Gets a `HarnessPredicate` that can be used to search for a `MatStepHarness` that meets
  37. * certain criteria.
  38. * @param options Options for filtering which steps are considered a match.
  39. * @return a `HarnessPredicate` configured with the given options.
  40. */
  41. static with(options?: StepHarnessFilters): HarnessPredicate<MatStepHarness>;
  42. /** Gets the label of the step. */
  43. getLabel(): Promise<string>;
  44. /** Gets the `aria-label` of the step. */
  45. getAriaLabel(): Promise<string | null>;
  46. /** Gets the value of the `aria-labelledby` attribute. */
  47. getAriaLabelledby(): Promise<string | null>;
  48. /** Whether the step is selected. */
  49. isSelected(): Promise<boolean>;
  50. /** Whether the step has been filled out. */
  51. isCompleted(): Promise<boolean>;
  52. /**
  53. * Whether the step is currently showing its error state. Note that this doesn't mean that there
  54. * are or aren't any invalid form controls inside the step, but that the step is showing its
  55. * error-specific styling which depends on there being invalid controls, as well as the
  56. * `ErrorStateMatcher` determining that an error should be shown and that the `showErrors`
  57. * option was enabled through the `STEPPER_GLOBAL_OPTIONS` injection token.
  58. */
  59. hasErrors(): Promise<boolean>;
  60. /** Whether the step is optional. */
  61. isOptional(): Promise<boolean>;
  62. /**
  63. * Selects the given step by clicking on the label. The step may not be selected
  64. * if the stepper doesn't allow it (e.g. if there are validation errors).
  65. */
  66. select(): Promise<void>;
  67. protected getRootHarnessLoader(): Promise<HarnessLoader>;
  68. /**
  69. * Gets the state of the step. Note that we have a `StepState` which we could use to type the
  70. * return value, but it's basically the same as `string`, because the type has `| string`.
  71. */
  72. private _getIconState;
  73. }
  74. /** Harness for interacting with a standard Material stepper in tests. */
  75. declare class MatStepperHarness extends ComponentHarness {
  76. /** The selector for the host element of a `MatStepper` instance. */
  77. static hostSelector: string;
  78. /**
  79. * Gets a `HarnessPredicate` that can be used to search for a `MatStepperHarness` that meets
  80. * certain criteria.
  81. * @param options Options for filtering which stepper instances are considered a match.
  82. * @return a `HarnessPredicate` configured with the given options.
  83. */
  84. static with(options?: StepperHarnessFilters): HarnessPredicate<MatStepperHarness>;
  85. /**
  86. * Gets the list of steps in the stepper.
  87. * @param filter Optionally filters which steps are included.
  88. */
  89. getSteps(filter?: StepHarnessFilters): Promise<MatStepHarness[]>;
  90. /** Gets the orientation of the stepper. */
  91. getOrientation(): Promise<StepperOrientation>;
  92. /**
  93. * Selects a step in this stepper.
  94. * @param filter An optional filter to apply to the child steps. The first step matching the
  95. * filter will be selected.
  96. */
  97. selectStep(filter?: StepHarnessFilters): Promise<void>;
  98. }
  99. /** Base class for stepper button harnesses. */
  100. declare abstract class StepperButtonHarness extends ComponentHarness {
  101. /** Gets the text of the button. */
  102. getText(): Promise<string>;
  103. /** Clicks the button. */
  104. click(): Promise<void>;
  105. }
  106. /** Harness for interacting with a standard Angular Material stepper next button in tests. */
  107. declare class MatStepperNextHarness extends StepperButtonHarness {
  108. /** The selector for the host element of a `MatStep` instance. */
  109. static hostSelector: string;
  110. /**
  111. * Gets a `HarnessPredicate` that can be used to search for a `MatStepperNextHarness` that meets
  112. * certain criteria.
  113. * @param options Options for filtering which steps are considered a match.
  114. * @return a `HarnessPredicate` configured with the given options.
  115. */
  116. static with(options?: StepperButtonHarnessFilters): HarnessPredicate<MatStepperNextHarness>;
  117. }
  118. /** Harness for interacting with a standard Angular Material stepper previous button in tests. */
  119. declare class MatStepperPreviousHarness extends StepperButtonHarness {
  120. /** The selector for the host element of a `MatStep` instance. */
  121. static hostSelector: string;
  122. /**
  123. * Gets a `HarnessPredicate` that can be used to search for a `MatStepperPreviousHarness`
  124. * that meets certain criteria.
  125. * @param options Options for filtering which steps are considered a match.
  126. * @return a `HarnessPredicate` configured with the given options.
  127. */
  128. static with(options?: StepperButtonHarnessFilters): HarnessPredicate<MatStepperPreviousHarness>;
  129. }
  130. export { MatStepHarness, MatStepperHarness, MatStepperNextHarness, MatStepperPreviousHarness, StepperOrientation };
  131. export type { StepHarnessFilters, StepperButtonHarnessFilters, StepperHarnessFilters };