index.d.ts 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { BaseHarnessFilters, ComponentHarnessConstructor, HarnessPredicate } from '@angular/cdk/testing';
  2. import { O as OptionHarnessFilters, M as MatOptionHarness } from '../../option-harness.d-IqsW95GR.js';
  3. import { OptgroupHarnessFilters, MatOptgroupHarness } from '../../core/testing/index.js';
  4. import { MatFormFieldControlHarness } from '../../form-field/testing/control/index.js';
  5. /** A set of criteria that can be used to filter a list of `MatSelectHarness` instances. */
  6. interface SelectHarnessFilters extends BaseHarnessFilters {
  7. /** Only find instances which match the given disabled state. */
  8. disabled?: boolean;
  9. }
  10. /** Harness for interacting with a mat-select in tests. */
  11. declare class MatSelectHarness extends MatFormFieldControlHarness {
  12. static hostSelector: string;
  13. private _prefix;
  14. private _optionClass;
  15. private _optionGroupClass;
  16. private _documentRootLocator;
  17. private _backdrop;
  18. /**
  19. * Gets a `HarnessPredicate` that can be used to search for a select with specific attributes.
  20. * @param options Options for filtering which select instances are considered a match.
  21. * @return a `HarnessPredicate` configured with the given options.
  22. */
  23. static with<T extends MatSelectHarness>(this: ComponentHarnessConstructor<T>, options?: SelectHarnessFilters): HarnessPredicate<T>;
  24. /** Gets a boolean promise indicating if the select is disabled. */
  25. isDisabled(): Promise<boolean>;
  26. /** Gets a boolean promise indicating if the select is valid. */
  27. isValid(): Promise<boolean>;
  28. /** Gets a boolean promise indicating if the select is required. */
  29. isRequired(): Promise<boolean>;
  30. /** Gets a boolean promise indicating if the select is empty (no value is selected). */
  31. isEmpty(): Promise<boolean>;
  32. /** Gets a boolean promise indicating if the select is in multi-selection mode. */
  33. isMultiple(): Promise<boolean>;
  34. /** Gets a promise for the select's value text. */
  35. getValueText(): Promise<string>;
  36. /** Focuses the select and returns a void promise that indicates when the action is complete. */
  37. focus(): Promise<void>;
  38. /** Blurs the select and returns a void promise that indicates when the action is complete. */
  39. blur(): Promise<void>;
  40. /** Whether the select is focused. */
  41. isFocused(): Promise<boolean>;
  42. /** Gets the options inside the select panel. */
  43. getOptions(filter?: Omit<OptionHarnessFilters, 'ancestor'>): Promise<MatOptionHarness[]>;
  44. /** Gets the groups of options inside the panel. */
  45. getOptionGroups(filter?: Omit<OptgroupHarnessFilters, 'ancestor'>): Promise<MatOptgroupHarness[]>;
  46. /** Gets whether the select is open. */
  47. isOpen(): Promise<boolean>;
  48. /** Opens the select's panel. */
  49. open(): Promise<void>;
  50. /**
  51. * Clicks the options that match the passed-in filter. If the select is in multi-selection
  52. * mode all options will be clicked, otherwise the harness will pick the first matching option.
  53. */
  54. clickOptions(filter?: OptionHarnessFilters): Promise<void>;
  55. /** Closes the select's panel. */
  56. close(): Promise<void>;
  57. /** Gets the selector that should be used to find this select's panel. */
  58. private _getPanelSelector;
  59. }
  60. export { MatSelectHarness };
  61. export type { SelectHarnessFilters };