import { UniDriver } from '@wix/wix-ui-test-utils/unidriver';
import { baseUniDriverFactory } from '../../../../unidriver';

export function ColorViewUniDriver(base: UniDriver) {
  const text = base.$('[data-hook="cell-color-view-text"]');
  const fillPreview = base.$('[data-hook="cell-color-view-fill-preview"]');

  return {
    ...baseUniDriverFactory(base),
    getHex: () => text.text(),
    hasText: () => text.exists(),
    hasFillPreview: () => fillPreview.exists(),
    /** Whether the FillPreview is filled (has a `fill` attribute style). */
    getFillStyle: () => fillPreview.attr('style') as Promise<string | null>,
  };
}
