index.d.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. import * as _angular_cdk_testing from '@angular/cdk/testing';
  2. import { BaseHarnessFilters, ComponentHarness, ComponentHarnessConstructor, HarnessPredicate, ContentContainerComponentHarness, TestKey } from '@angular/cdk/testing';
  3. interface ChipHarnessFilters extends BaseHarnessFilters {
  4. /** Only find instances whose text matches the given value. */
  5. text?: string | RegExp;
  6. /** Only find instances which match the given disabled state. */
  7. disabled?: boolean;
  8. }
  9. interface ChipInputHarnessFilters extends BaseHarnessFilters {
  10. /** Filters based on the value of the input. */
  11. value?: string | RegExp;
  12. /** Filters based on the placeholder text of the input. */
  13. placeholder?: string | RegExp;
  14. /** Only find instances which match the given disabled state. */
  15. disabled?: boolean;
  16. }
  17. interface ChipListboxHarnessFilters extends BaseHarnessFilters {
  18. /** Only find instances which match the given disabled state. */
  19. disabled?: boolean;
  20. }
  21. interface ChipOptionHarnessFilters extends ChipHarnessFilters {
  22. /** Only find chip instances whose selected state matches the given value. */
  23. selected?: boolean;
  24. }
  25. interface ChipGridHarnessFilters extends BaseHarnessFilters {
  26. /** Only find instances which match the given disabled state. */
  27. disabled?: boolean;
  28. }
  29. interface ChipRowHarnessFilters extends ChipHarnessFilters {
  30. }
  31. interface ChipSetHarnessFilters extends BaseHarnessFilters {
  32. }
  33. interface ChipRemoveHarnessFilters extends BaseHarnessFilters {
  34. }
  35. interface ChipAvatarHarnessFilters extends BaseHarnessFilters {
  36. }
  37. interface ChipEditInputHarnessFilters extends BaseHarnessFilters {
  38. }
  39. /** Harness for interacting with a standard Material chip avatar in tests. */
  40. declare class MatChipAvatarHarness extends ComponentHarness {
  41. static hostSelector: string;
  42. /**
  43. * Gets a `HarnessPredicate` that can be used to search for a chip avatar with specific
  44. * attributes.
  45. * @param options Options for filtering which input instances are considered a match.
  46. * @return a `HarnessPredicate` configured with the given options.
  47. */
  48. static with<T extends MatChipAvatarHarness>(this: ComponentHarnessConstructor<T>, options?: ChipAvatarHarnessFilters): HarnessPredicate<T>;
  49. }
  50. /** Harness for interacting with a standard Material chip remove button in tests. */
  51. declare class MatChipRemoveHarness extends ComponentHarness {
  52. static hostSelector: string;
  53. /**
  54. * Gets a `HarnessPredicate` that can be used to search for a chip remove with specific
  55. * attributes.
  56. * @param options Options for filtering which input instances are considered a match.
  57. * @return a `HarnessPredicate` configured with the given options.
  58. */
  59. static with<T extends MatChipRemoveHarness>(this: ComponentHarnessConstructor<T>, options?: ChipRemoveHarnessFilters): HarnessPredicate<T>;
  60. /** Clicks the remove button. */
  61. click(): Promise<void>;
  62. }
  63. /** Harness for interacting with a mat-chip in tests. */
  64. declare class MatChipHarness extends ContentContainerComponentHarness {
  65. protected _primaryAction: () => Promise<_angular_cdk_testing.TestElement>;
  66. static hostSelector: string;
  67. /**
  68. * Gets a `HarnessPredicate` that can be used to search for a chip with specific attributes.
  69. * @param options Options for narrowing the search.
  70. * @return a `HarnessPredicate` configured with the given options.
  71. */
  72. static with<T extends MatChipHarness>(this: ComponentHarnessConstructor<T>, options?: ChipHarnessFilters): HarnessPredicate<T>;
  73. /** Gets a promise for the text content the option. */
  74. getText(): Promise<string>;
  75. /** Whether the chip is disabled. */
  76. isDisabled(): Promise<boolean>;
  77. /** Delete a chip from the set. */
  78. remove(): Promise<void>;
  79. /**
  80. * Gets the remove button inside of a chip.
  81. * @param filter Optionally filters which chips are included.
  82. */
  83. getRemoveButton(filter?: ChipRemoveHarnessFilters): Promise<MatChipRemoveHarness>;
  84. /**
  85. * Gets the avatar inside a chip.
  86. * @param filter Optionally filters which avatars are included.
  87. */
  88. getAvatar(filter?: ChipAvatarHarnessFilters): Promise<MatChipAvatarHarness | null>;
  89. }
  90. /** Harness for interacting with a grid's chip input in tests. */
  91. declare class MatChipInputHarness extends ComponentHarness {
  92. static hostSelector: string;
  93. /**
  94. * Gets a `HarnessPredicate` that can be used to search for a chip input with specific
  95. * attributes.
  96. * @param options Options for filtering which input instances are considered a match.
  97. * @return a `HarnessPredicate` configured with the given options.
  98. */
  99. static with<T extends MatChipInputHarness>(this: ComponentHarnessConstructor<T>, options?: ChipInputHarnessFilters): HarnessPredicate<T>;
  100. /** Whether the input is disabled. */
  101. isDisabled(): Promise<boolean>;
  102. /** Whether the input is required. */
  103. isRequired(): Promise<boolean>;
  104. /** Gets the value of the input. */
  105. getValue(): Promise<string>;
  106. /** Gets the placeholder of the input. */
  107. getPlaceholder(): Promise<string>;
  108. /**
  109. * Focuses the input and returns a promise that indicates when the
  110. * action is complete.
  111. */
  112. focus(): Promise<void>;
  113. /**
  114. * Blurs the input and returns a promise that indicates when the
  115. * action is complete.
  116. */
  117. blur(): Promise<void>;
  118. /** Whether the input is focused. */
  119. isFocused(): Promise<boolean>;
  120. /**
  121. * Sets the value of the input. The value will be set by simulating
  122. * keypresses that correspond to the given value.
  123. */
  124. setValue(newValue: string): Promise<void>;
  125. /** Sends a chip separator key to the input element. */
  126. sendSeparatorKey(key: TestKey | string): Promise<void>;
  127. }
  128. /** Harness for interacting with a mat-chip-option in tests. */
  129. declare class MatChipOptionHarness extends MatChipHarness {
  130. static hostSelector: string;
  131. /**
  132. * Gets a `HarnessPredicate` that can be used to search for a chip option with specific
  133. * attributes.
  134. * @param options Options for narrowing the search.
  135. * @return a `HarnessPredicate` configured with the given options.
  136. */
  137. static with<T extends MatChipHarness>(this: ComponentHarnessConstructor<T>, options?: ChipOptionHarnessFilters): HarnessPredicate<T>;
  138. /** Whether the chip is selected. */
  139. isSelected(): Promise<boolean>;
  140. /** Selects the given chip. Only applies if it's selectable. */
  141. select(): Promise<void>;
  142. /** Deselects the given chip. Only applies if it's selectable. */
  143. deselect(): Promise<void>;
  144. /** Toggles the selected state of the given chip. */
  145. toggle(): Promise<void>;
  146. }
  147. /** Harness for interacting with a mat-chip-listbox in tests. */
  148. declare class MatChipListboxHarness extends ComponentHarness {
  149. static hostSelector: string;
  150. /**
  151. * Gets a `HarnessPredicate` that can be used to search for a chip listbox with specific
  152. * attributes.
  153. * @param options Options for narrowing the search.
  154. * @return a `HarnessPredicate` configured with the given options.
  155. */
  156. static with<T extends MatChipListboxHarness>(this: ComponentHarnessConstructor<T>, options?: ChipListboxHarnessFilters): HarnessPredicate<T>;
  157. /** Gets whether the chip listbox is disabled. */
  158. isDisabled(): Promise<boolean>;
  159. /** Gets whether the chip listbox is required. */
  160. isRequired(): Promise<boolean>;
  161. /** Gets whether the chip listbox is in multi selection mode. */
  162. isMultiple(): Promise<boolean>;
  163. /** Gets whether the orientation of the chip list. */
  164. getOrientation(): Promise<'horizontal' | 'vertical'>;
  165. /**
  166. * Gets the list of chips inside the chip list.
  167. * @param filter Optionally filters which chips are included.
  168. */
  169. getChips(filter?: ChipOptionHarnessFilters): Promise<MatChipOptionHarness[]>;
  170. /**
  171. * Selects a chip inside the chip list.
  172. * @param filter An optional filter to apply to the child chips.
  173. * All the chips matching the filter will be selected.
  174. */
  175. selectChips(filter?: ChipOptionHarnessFilters): Promise<void>;
  176. }
  177. /** Harness for interacting with an editable chip's input in tests. */
  178. declare class MatChipEditInputHarness extends ComponentHarness {
  179. static hostSelector: string;
  180. /**
  181. * Gets a `HarnessPredicate` that can be used to search for a chip edit input with specific
  182. * attributes.
  183. * @param options Options for filtering which input instances are considered a match.
  184. * @return a `HarnessPredicate` configured with the given options.
  185. */
  186. static with<T extends MatChipEditInputHarness>(this: ComponentHarnessConstructor<T>, options?: ChipEditInputHarnessFilters): HarnessPredicate<T>;
  187. /** Sets the value of the input. */
  188. setValue(value: string): Promise<void>;
  189. }
  190. /** Harness for interacting with a mat-chip-row in tests. */
  191. declare class MatChipRowHarness extends MatChipHarness {
  192. static hostSelector: string;
  193. /** Whether the chip is editable. */
  194. isEditable(): Promise<boolean>;
  195. /** Whether the chip is currently being edited. */
  196. isEditing(): Promise<boolean>;
  197. /** Sets the chip row into an editing state, if it is editable. */
  198. startEditing(): Promise<void>;
  199. /** Stops editing the chip, if it was in the editing state. */
  200. finishEditing(): Promise<void>;
  201. /** Gets the edit input inside the chip row. */
  202. getEditInput(filter?: ChipEditInputHarnessFilters): Promise<MatChipEditInputHarness>;
  203. }
  204. /** Harness for interacting with a mat-chip-grid in tests. */
  205. declare class MatChipGridHarness extends ComponentHarness {
  206. static hostSelector: string;
  207. /**
  208. * Gets a `HarnessPredicate` that can be used to search for a chip grid with specific attributes.
  209. * @param options Options for filtering which chip grid instances are considered a match.
  210. * @return a `HarnessPredicate` configured with the given options.
  211. */
  212. static with<T extends MatChipGridHarness>(this: ComponentHarnessConstructor<T>, options?: ChipGridHarnessFilters): HarnessPredicate<T>;
  213. /** Gets whether the chip grid is disabled. */
  214. isDisabled(): Promise<boolean>;
  215. /** Gets whether the chip grid is required. */
  216. isRequired(): Promise<boolean>;
  217. /** Gets whether the chip grid is invalid. */
  218. isInvalid(): Promise<boolean>;
  219. /** Gets promise of the harnesses for the chip rows. */
  220. getRows(filter?: ChipRowHarnessFilters): Promise<MatChipRowHarness[]>;
  221. /** Gets promise of the chip text input harness. */
  222. getInput(filter?: ChipInputHarnessFilters): Promise<MatChipInputHarness | null>;
  223. }
  224. /** Harness for interacting with a mat-chip-set in tests. */
  225. declare class MatChipSetHarness extends ComponentHarness {
  226. static hostSelector: string;
  227. /**
  228. * Gets a `HarnessPredicate` that can be used to search for a chip set with specific attributes.
  229. * @param options Options for filtering which chip set instances are considered a match.
  230. * @return a `HarnessPredicate` configured with the given options.
  231. */
  232. static with<T extends MatChipSetHarness>(this: ComponentHarnessConstructor<T>, options?: ChipSetHarnessFilters): HarnessPredicate<T>;
  233. /** Gets promise of the harnesses for the chips. */
  234. getChips(filter?: ChipHarnessFilters): Promise<MatChipHarness[]>;
  235. }
  236. export { MatChipAvatarHarness, MatChipEditInputHarness, MatChipGridHarness, MatChipHarness, MatChipInputHarness, MatChipListboxHarness, MatChipOptionHarness, MatChipRemoveHarness, MatChipRowHarness, MatChipSetHarness };
  237. export type { ChipAvatarHarnessFilters, ChipEditInputHarnessFilters, ChipGridHarnessFilters, ChipHarnessFilters, ChipInputHarnessFilters, ChipListboxHarnessFilters, ChipOptionHarnessFilters, ChipRemoveHarnessFilters, ChipRowHarnessFilters, ChipSetHarnessFilters };