import { TextButtonUniDriver } from '@wix/design-system/dist/testkit/unidriver';
import { UniDriver } from '@wix/wix-ui-test-utils/unidriver';

export function ExpandCollapseAllButtonUniDriver(
  base: UniDriver,
  body: UniDriver,
) {
  const getButton = () =>
    base.$('[data-hook="nested-table-expand-collapse-all-button"]');
  const expandIcon = () => getButton().$('[data-hook="expand-icon"]');
  const collapseIcon = () => getButton().$('[data-hook="collapse-icon"]');
  return {
    ...TextButtonUniDriver(getButton(), body),
    isExpanded: () => expandIcon().exists(),
    isCollapsed: () => collapseIcon().exists(),
  };
}
