Skip to content

Commit

Permalink
fix(material/menu): fix harness test
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewseguin committed Aug 11, 2023
1 parent 99d034e commit e829ab8
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/material/menu/testing/menu-harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {MenuHarnessFilters, MenuItemHarnessFilters} from './menu-harness-filters

/** Harness for interacting with an MDC-based mat-menu in tests. */
export class MatMenuHarness extends ContentContainerComponentHarness<string> {
private _documentRootLocator = this.documentRootLocatorFactory();

/** The selector for the host element of a `MatMenu` instance. */
static hostSelector = '.mat-mdc-menu-trigger';

Expand All @@ -38,11 +40,6 @@ export class MatMenuHarness extends ContentContainerComponentHarness<string> {
);
}

private _documentRootLocator = this.documentRootLocatorFactory();
private _itemClass = MatMenuItemHarness;

// TODO: potentially extend MatLegacyButtonHarness

/** Whether the menu is disabled. */
async isDisabled(): Promise<boolean> {
const disabled = (await this.host()).getAttribute('disabled');
Expand Down Expand Up @@ -99,7 +96,7 @@ export class MatMenuHarness extends ContentContainerComponentHarness<string> {
const panelId = await this._getPanelId();
if (panelId) {
return this._documentRootLocator.locatorForAll(
this._itemClass.with({
MatMenuItemHarness.with({
...(filters || {}),
ancestor: `#${panelId}`,
} as MenuItemHarnessFilters),
Expand Down Expand Up @@ -134,7 +131,7 @@ export class MatMenuHarness extends ContentContainerComponentHarness<string> {
if (!menu) {
throw Error(`Item matching ${JSON.stringify(itemFilter)} does not have a submenu`);
}
return menu.clickItem(subItemFilters as Omit<MenuItemHarnessFilters, 'ancestor'>);
return menu.clickItem(...(subItemFilters as [Omit<MenuItemHarnessFilters, 'ancestor'>]));
}

protected override async getRootHarnessLoader(): Promise<HarnessLoader> {
Expand Down

0 comments on commit e829ab8

Please sign in to comment.