index.d.ts 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. import { BaseHarnessFilters, ContentContainerComponentHarness, ComponentHarnessConstructor, HarnessPredicate, HarnessLoader, ComponentHarness } from '@angular/cdk/testing';
  2. /** A set of criteria that can be used to filter a list of `MatTabHarness` instances. */
  3. interface TabHarnessFilters extends BaseHarnessFilters {
  4. /** Only find instances whose label matches the given value. */
  5. label?: string | RegExp;
  6. /** Only find instances whose selected state matches the given value. */
  7. selected?: boolean;
  8. }
  9. /** A set of criteria that can be used to filter a list of `MatTabGroupHarness` instances. */
  10. interface TabGroupHarnessFilters extends BaseHarnessFilters {
  11. /** Only find instances whose selected tab label matches the given value. */
  12. selectedTabLabel?: string | RegExp;
  13. }
  14. /** A set of criteria that can be used to filter a list of `MatTabLinkHarness` instances. */
  15. interface TabLinkHarnessFilters extends BaseHarnessFilters {
  16. /** Only find instances whose label matches the given value. */
  17. label?: string | RegExp;
  18. }
  19. /** A set of criteria that can be used to filter a list of `MatTabNavBarHarness` instances. */
  20. interface TabNavBarHarnessFilters extends BaseHarnessFilters {
  21. }
  22. /** A set of criteria that can be used to filter a list of `MatTabNavPanelHarness` instances. */
  23. interface TabNavPanelHarnessFilters extends BaseHarnessFilters {
  24. }
  25. /** Harness for interacting with an Angular Material tab in tests. */
  26. declare class MatTabHarness extends ContentContainerComponentHarness<string> {
  27. /** The selector for the host element of a `MatTab` instance. */
  28. static hostSelector: string;
  29. /**
  30. * Gets a `HarnessPredicate` that can be used to search for a tab with specific attributes.
  31. * @param options Options for filtering which tab instances are considered a match.
  32. * @return a `HarnessPredicate` configured with the given options.
  33. */
  34. static with<T extends MatTabHarness>(this: ComponentHarnessConstructor<T>, options?: TabHarnessFilters): HarnessPredicate<T>;
  35. /** Gets the label of the tab. */
  36. getLabel(): Promise<string>;
  37. /** Gets the aria-label of the tab. */
  38. getAriaLabel(): Promise<string | null>;
  39. /** Gets the value of the "aria-labelledby" attribute. */
  40. getAriaLabelledby(): Promise<string | null>;
  41. /** Whether the tab is selected. */
  42. isSelected(): Promise<boolean>;
  43. /** Whether the tab is disabled. */
  44. isDisabled(): Promise<boolean>;
  45. /** Selects the given tab by clicking on the label. Tab cannot be selected if disabled. */
  46. select(): Promise<void>;
  47. /** Gets the text content of the tab. */
  48. getTextContent(): Promise<string>;
  49. protected getRootHarnessLoader(): Promise<HarnessLoader>;
  50. /** Gets the element id for the content of the current tab. */
  51. private _getContentId;
  52. }
  53. /** Harness for interacting with a mat-tab-group in tests. */
  54. declare class MatTabGroupHarness extends ComponentHarness {
  55. /** The selector for the host element of a `MatTabGroup` instance. */
  56. static hostSelector: string;
  57. /**
  58. * Gets a `HarnessPredicate` that can be used to search for a tab group with specific attributes.
  59. * @param options Options for filtering which tab group instances are considered a match.
  60. * @return a `HarnessPredicate` configured with the given options.
  61. */
  62. static with<T extends MatTabGroupHarness>(this: ComponentHarnessConstructor<T>, options?: TabGroupHarnessFilters): HarnessPredicate<T>;
  63. /**
  64. * Gets the list of tabs in the tab group.
  65. * @param filter Optionally filters which tabs are included.
  66. */
  67. getTabs(filter?: TabHarnessFilters): Promise<MatTabHarness[]>;
  68. /** Gets the selected tab of the tab group. */
  69. getSelectedTab(): Promise<MatTabHarness>;
  70. /**
  71. * Selects a tab in this tab group.
  72. * @param filter An optional filter to apply to the child tabs. The first tab matching the filter
  73. * will be selected.
  74. */
  75. selectTab(filter?: TabHarnessFilters): Promise<void>;
  76. }
  77. /** Harness for interacting with a Angular Material tab link in tests. */
  78. declare class MatTabLinkHarness extends ComponentHarness {
  79. /** The selector for the host element of a `MatTabLink` instance. */
  80. static hostSelector: string;
  81. /**
  82. * Gets a `HarnessPredicate` that can be used to search for a tab link with specific attributes.
  83. * @param options Options for filtering which tab link instances are considered a match.
  84. * @return a `HarnessPredicate` configured with the given options.
  85. */
  86. static with<T extends MatTabLinkHarness>(this: ComponentHarnessConstructor<T>, options?: TabLinkHarnessFilters): HarnessPredicate<T>;
  87. /** Gets the label of the link. */
  88. getLabel(): Promise<string>;
  89. /** Whether the link is active. */
  90. isActive(): Promise<boolean>;
  91. /** Whether the link is disabled. */
  92. isDisabled(): Promise<boolean>;
  93. /** Clicks on the link. */
  94. click(): Promise<void>;
  95. }
  96. /** Harness for interacting with a standard mat-tab-nav-panel in tests. */
  97. declare class MatTabNavPanelHarness extends ContentContainerComponentHarness {
  98. /** The selector for the host element of a `MatTabNavPanel` instance. */
  99. static hostSelector: string;
  100. /**
  101. * Gets a `HarnessPredicate` that can be used to search for a tab nav panel with specific
  102. * attributes.
  103. * @param options Options for filtering which tab nav panel instances are considered a match.
  104. * @return a `HarnessPredicate` configured with the given options.
  105. */
  106. static with<T extends MatTabNavPanelHarness>(this: ComponentHarnessConstructor<T>, options?: TabNavPanelHarnessFilters): HarnessPredicate<T>;
  107. /** Gets the tab panel text content. */
  108. getTextContent(): Promise<string>;
  109. }
  110. /** Harness for interacting with a mat-tab-nav-bar in tests. */
  111. declare class MatTabNavBarHarness extends ComponentHarness {
  112. /** The selector for the host element of a `MatTabNavBar` instance. */
  113. static hostSelector: string;
  114. /**
  115. * Gets a `HarnessPredicate` that can be used to search for a tab nav bar with specific
  116. * attributes.
  117. * @param options Options for filtering which tab nav bar instances are considered a match.
  118. * @return a `HarnessPredicate` configured with the given options.
  119. */
  120. static with<T extends MatTabNavBarHarness>(this: ComponentHarnessConstructor<T>, options?: TabNavBarHarnessFilters): HarnessPredicate<T>;
  121. /**
  122. * Gets the list of links in the nav bar.
  123. * @param filter Optionally filters which links are included.
  124. */
  125. getLinks(filter?: TabLinkHarnessFilters): Promise<MatTabLinkHarness[]>;
  126. /** Gets the active link in the nav bar. */
  127. getActiveLink(): Promise<MatTabLinkHarness>;
  128. /**
  129. * Clicks a link inside the nav bar.
  130. * @param filter An optional filter to apply to the child link. The first link matching the filter
  131. * will be clicked.
  132. */
  133. clickLink(filter?: TabLinkHarnessFilters): Promise<void>;
  134. /** Gets the panel associated with the nav bar. */
  135. getPanel(): Promise<MatTabNavPanelHarness>;
  136. }
  137. export { MatTabGroupHarness, MatTabHarness, MatTabLinkHarness, MatTabNavBarHarness };
  138. export type { TabGroupHarnessFilters, TabHarnessFilters, TabLinkHarnessFilters, TabNavBarHarnessFilters, TabNavPanelHarnessFilters };