index.d.ts 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import { BaseHarnessFilters, ContentContainerComponentHarness, HarnessPredicate, HarnessLoader, ComponentHarness } from '@angular/cdk/testing';
  2. interface AccordionHarnessFilters extends BaseHarnessFilters {
  3. }
  4. interface ExpansionPanelHarnessFilters extends BaseHarnessFilters {
  5. title?: string | RegExp | null;
  6. description?: string | RegExp | null;
  7. content?: string | RegExp;
  8. expanded?: boolean;
  9. disabled?: boolean;
  10. }
  11. /** Selectors for the various `mat-expansion-panel` sections that may contain user content. */
  12. declare enum MatExpansionPanelSection {
  13. HEADER = ".mat-expansion-panel-header",
  14. TITLE = ".mat-expansion-panel-header-title",
  15. DESCRIPTION = ".mat-expansion-panel-header-description",
  16. CONTENT = ".mat-expansion-panel-content"
  17. }
  18. /** Harness for interacting with a standard mat-expansion-panel in tests. */
  19. declare class MatExpansionPanelHarness extends ContentContainerComponentHarness<MatExpansionPanelSection> {
  20. static hostSelector: string;
  21. private _header;
  22. private _title;
  23. private _description;
  24. private _expansionIndicator;
  25. private _content;
  26. /**
  27. * Gets a `HarnessPredicate` that can be used to search for an expansion-panel
  28. * with specific attributes.
  29. * @param options Options for narrowing the search:
  30. * - `title` finds an expansion-panel with a specific title text.
  31. * - `description` finds an expansion-panel with a specific description text.
  32. * - `expanded` finds an expansion-panel that is currently expanded.
  33. * - `disabled` finds an expansion-panel that is disabled.
  34. * @return a `HarnessPredicate` configured with the given options.
  35. */
  36. static with(options?: ExpansionPanelHarnessFilters): HarnessPredicate<MatExpansionPanelHarness>;
  37. /** Whether the panel is expanded. */
  38. isExpanded(): Promise<boolean>;
  39. /**
  40. * Gets the title text of the panel.
  41. * @returns Title text or `null` if no title is set up.
  42. */
  43. getTitle(): Promise<string | null>;
  44. /**
  45. * Gets the description text of the panel.
  46. * @returns Description text or `null` if no description is set up.
  47. */
  48. getDescription(): Promise<string | null>;
  49. /** Whether the panel is disabled. */
  50. isDisabled(): Promise<boolean>;
  51. /**
  52. * Toggles the expanded state of the panel by clicking on the panel
  53. * header. This method will not work if the panel is disabled.
  54. */
  55. toggle(): Promise<void>;
  56. /** Expands the expansion panel if collapsed. */
  57. expand(): Promise<void>;
  58. /** Collapses the expansion panel if expanded. */
  59. collapse(): Promise<void>;
  60. /** Gets the text content of the panel. */
  61. getTextContent(): Promise<string>;
  62. /**
  63. * Gets a `HarnessLoader` that can be used to load harnesses for
  64. * components within the panel's content area.
  65. * @deprecated Use either `getChildLoader(MatExpansionPanelSection.CONTENT)`, `getHarness` or
  66. * `getAllHarnesses` instead.
  67. * @breaking-change 12.0.0
  68. */
  69. getHarnessLoaderForContent(): Promise<HarnessLoader>;
  70. /** Focuses the panel. */
  71. focus(): Promise<void>;
  72. /** Blurs the panel. */
  73. blur(): Promise<void>;
  74. /** Whether the panel is focused. */
  75. isFocused(): Promise<boolean>;
  76. /** Whether the panel has a toggle indicator displayed. */
  77. hasToggleIndicator(): Promise<boolean>;
  78. /** Gets the position of the toggle indicator. */
  79. getToggleIndicatorPosition(): Promise<'before' | 'after'>;
  80. }
  81. /** Harness for interacting with a standard mat-accordion in tests. */
  82. declare class MatAccordionHarness extends ComponentHarness {
  83. static hostSelector: string;
  84. /**
  85. * Gets a `HarnessPredicate` that can be used to search for an accordion
  86. * with specific attributes.
  87. * @param options Options for narrowing the search.
  88. * @return a `HarnessPredicate` configured with the given options.
  89. */
  90. static with(options?: AccordionHarnessFilters): HarnessPredicate<MatAccordionHarness>;
  91. /** Gets all expansion panels which are part of the accordion. */
  92. getExpansionPanels(filter?: ExpansionPanelHarnessFilters): Promise<MatExpansionPanelHarness[]>;
  93. /** Whether the accordion allows multiple expanded panels simultaneously. */
  94. isMulti(): Promise<boolean>;
  95. }
  96. export { MatAccordionHarness, MatExpansionPanelHarness, MatExpansionPanelSection };
  97. export type { AccordionHarnessFilters, ExpansionPanelHarnessFilters };