12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- import { BaseHarnessFilters, ContentContainerComponentHarness, ComponentHarnessConstructor, HarnessPredicate, HarnessLoader } from '@angular/cdk/testing';
- /** A set of criteria that can be used to filter a list of `MatMenuHarness` instances. */
- interface MenuHarnessFilters extends BaseHarnessFilters {
- /** Only find instances whose trigger text matches the given value. */
- triggerText?: string | RegExp;
- }
- /** A set of criteria that can be used to filter a list of `MatMenuItemHarness` instances. */
- interface MenuItemHarnessFilters extends BaseHarnessFilters {
- /** Only find instances whose text matches the given value. */
- text?: string | RegExp;
- /** Only find instances that have a sub-menu. */
- hasSubmenu?: boolean;
- }
- /** Harness for interacting with a mat-menu in tests. */
- declare class MatMenuHarness extends ContentContainerComponentHarness<string> {
- private _documentRootLocator;
- /** The selector for the host element of a `MatMenu` instance. */
- static hostSelector: string;
- /**
- * Gets a `HarnessPredicate` that can be used to search for a menu with specific attributes.
- * @param options Options for filtering which menu instances are considered a match.
- * @return a `HarnessPredicate` configured with the given options.
- */
- static with<T extends MatMenuHarness>(this: ComponentHarnessConstructor<T>, options?: MenuHarnessFilters): HarnessPredicate<T>;
- /** Whether the menu is disabled. */
- isDisabled(): Promise<boolean>;
- /** Whether the menu is open. */
- isOpen(): Promise<boolean>;
- /** Gets the text of the menu's trigger element. */
- getTriggerText(): Promise<string>;
- /** Focuses the menu. */
- focus(): Promise<void>;
- /** Blurs the menu. */
- blur(): Promise<void>;
- /** Whether the menu is focused. */
- isFocused(): Promise<boolean>;
- /** Opens the menu. */
- open(): Promise<void>;
- /** Closes the menu. */
- close(): Promise<void>;
- /**
- * Gets a list of `MatMenuItemHarness` representing the items in the menu.
- * @param filters Optionally filters which menu items are included.
- */
- getItems(filters?: Omit<MenuItemHarnessFilters, 'ancestor'>): Promise<MatMenuItemHarness[]>;
- /**
- * Clicks an item in the menu, and optionally continues clicking items in subsequent sub-menus.
- * @param itemFilter A filter used to represent which item in the menu should be clicked. The
- * first matching menu item will be clicked.
- * @param subItemFilters A list of filters representing the items to click in any subsequent
- * sub-menus. The first item in the sub-menu matching the corresponding filter in
- * `subItemFilters` will be clicked.
- */
- clickItem(itemFilter: Omit<MenuItemHarnessFilters, 'ancestor'>, ...subItemFilters: Omit<MenuItemHarnessFilters, 'ancestor'>[]): Promise<void>;
- protected getRootHarnessLoader(): Promise<HarnessLoader>;
- /** Gets the menu panel associated with this menu. */
- private _getMenuPanel;
- /** Gets the id of the menu panel associated with this menu. */
- private _getPanelId;
- }
- declare class MatMenuItemHarness extends ContentContainerComponentHarness<string> {
- /** The selector for the host element of a `MatMenuItem` instance. */
- static hostSelector: string;
- /**
- * Gets a `HarnessPredicate` that can be used to search for a menu item with specific attributes.
- * @param options Options for filtering which menu item instances are considered a match.
- * @return a `HarnessPredicate` configured with the given options.
- */
- static with<T extends MatMenuItemHarness>(this: ComponentHarnessConstructor<T>, options?: MenuItemHarnessFilters): HarnessPredicate<T>;
- /** Whether the menu is disabled. */
- isDisabled(): Promise<boolean>;
- /** Gets the text of the menu item. */
- getText(): Promise<string>;
- /** Focuses the menu item. */
- focus(): Promise<void>;
- /** Blurs the menu item. */
- blur(): Promise<void>;
- /** Whether the menu item is focused. */
- isFocused(): Promise<boolean>;
- /** Clicks the menu item. */
- click(): Promise<void>;
- /** Whether this item has a submenu. */
- hasSubmenu(): Promise<boolean>;
- /** Gets the submenu associated with this menu item, or null if none. */
- getSubmenu(): Promise<MatMenuHarness | null>;
- }
- export { MatMenuHarness, MatMenuItemHarness };
- export type { MenuHarnessFilters, MenuItemHarnessFilters };
|