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

export function ExpandCollapseButtonUniDriver(
  base: UniDriver,
  body: UniDriver,
) {
  const getButton = () => base.$('[data-hook="expand-collapse"]');
  const chevronIcon = () => getButton().$('[data-hook="chevron-icon"]');
  return {
    ...TextButtonUniDriver(getButton(), body),
    isExpanded: async () =>
      (await chevronIcon().attr('style'))?.includes('transform: rotate(90deg)'),
    isCollapsed: async () =>
      (await chevronIcon().attr('style'))?.includes('transform: rotate(0deg)'),
    isHidden: async () =>
      (await base.attr('style'))?.includes('visibility: hidden'),
  };
}
