index.d.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import { BaseHarnessFilters, ComponentHarness, ComponentHarnessConstructor, HarnessPredicate } from '@angular/cdk/testing';
  2. /** Possible positions of a slider thumb. */
  3. declare enum ThumbPosition {
  4. START = 0,
  5. END = 1
  6. }
  7. /** A set of criteria that can be used to filter a list of `MatSliderHarness` instances. */
  8. interface SliderHarnessFilters extends BaseHarnessFilters {
  9. /** Filters out only range/non-range sliders. */
  10. isRange?: boolean;
  11. /** Only find instances which match the given disabled state. */
  12. disabled?: boolean;
  13. }
  14. /** A set of criteria that can be used to filter a list of `MatSliderThumbHarness` instances. */
  15. interface SliderThumbHarnessFilters extends BaseHarnessFilters {
  16. /** Filters out slider thumbs with a particular position. */
  17. position?: ThumbPosition;
  18. }
  19. /** Harness for interacting with a thumb inside of a Material slider in tests. */
  20. declare class MatSliderThumbHarness extends ComponentHarness {
  21. static hostSelector: string;
  22. /**
  23. * Gets a `HarnessPredicate` that can be used to search for a slider thumb with specific attributes.
  24. * @param options Options for filtering which thumb instances are considered a match.
  25. * @return a `HarnessPredicate` configured with the given options.
  26. */
  27. static with<T extends MatSliderThumbHarness>(this: ComponentHarnessConstructor<T>, options?: SliderThumbHarnessFilters): HarnessPredicate<T>;
  28. /** Gets the position of the thumb inside the slider. */
  29. getPosition(): Promise<ThumbPosition>;
  30. /** Gets the value of the thumb. */
  31. getValue(): Promise<number>;
  32. /** Sets the value of the thumb. */
  33. setValue(newValue: number): Promise<void>;
  34. /** Gets the current percentage value of the slider. */
  35. getPercentage(): Promise<number>;
  36. /** Gets the maximum value of the thumb. */
  37. getMaxValue(): Promise<number>;
  38. /** Gets the minimum value of the thumb. */
  39. getMinValue(): Promise<number>;
  40. /** Gets the text representation of the slider's value. */
  41. getDisplayValue(): Promise<string>;
  42. /** Whether the thumb is disabled. */
  43. isDisabled(): Promise<boolean>;
  44. /** Gets the name of the thumb. */
  45. getName(): Promise<string>;
  46. /** Gets the id of the thumb. */
  47. getId(): Promise<string>;
  48. /**
  49. * Focuses the thumb and returns a promise that indicates when the
  50. * action is complete.
  51. */
  52. focus(): Promise<void>;
  53. /**
  54. * Blurs the thumb and returns a promise that indicates when the
  55. * action is complete.
  56. */
  57. blur(): Promise<void>;
  58. /** Whether the thumb is focused. */
  59. isFocused(): Promise<boolean>;
  60. }
  61. /** Harness for interacting with a MDC mat-slider in tests. */
  62. declare class MatSliderHarness extends ComponentHarness {
  63. static hostSelector: string;
  64. /**
  65. * Gets a `HarnessPredicate` that can be used to search for a slider with specific attributes.
  66. * @param options Options for filtering which input instances are considered a match.
  67. * @return a `HarnessPredicate` configured with the given options.
  68. */
  69. static with<T extends MatSliderHarness>(this: ComponentHarnessConstructor<T>, options?: SliderHarnessFilters): HarnessPredicate<T>;
  70. /** Gets the start thumb of the slider (only applicable for range sliders). */
  71. getStartThumb(): Promise<MatSliderThumbHarness>;
  72. /** Gets the thumb (for single point sliders), or the end thumb (for range sliders). */
  73. getEndThumb(): Promise<MatSliderThumbHarness>;
  74. /** Gets whether the slider is a range slider. */
  75. isRange(): Promise<boolean>;
  76. /** Gets whether the slider is disabled. */
  77. isDisabled(): Promise<boolean>;
  78. /** Gets the value step increments of the slider. */
  79. getStep(): Promise<number>;
  80. /** Gets the maximum value of the slider. */
  81. getMaxValue(): Promise<number>;
  82. /** Gets the minimum value of the slider. */
  83. getMinValue(): Promise<number>;
  84. }
  85. export { MatSliderHarness, MatSliderThumbHarness, ThumbPosition };
  86. export type { SliderHarnessFilters, SliderThumbHarnessFilters };