simontonsoftware / s-libs

A collection of libraries for any of javascript, rxjs, or angular.
MIT License
43 stars 5 forks source link

[ng-dev] Feature request: `getIconButtonHarness()` #107

Closed ersimont closed 1 year ago

ersimont commented 1 year ago
export async function getIconButtonHarness(
  iconName: string,
  parent: ContentContainerComponentHarness,
): Promise<MatButtonHarness> {
  const buttons = await parent.getAllHarnesses(MatButtonHarness);
  for (const button of buttons) {
    const icons = await button.getAllHarnesses(
      MatIconHarness.with({ name: iconName }),
    );
    if (icons.length) {
      return button;
    }
  }
  throw new Error('No button found with icon ' + iconName);
}