import { UniDriver } from '@wix/wix-ui-test-utils/unidriver';
import { InputUniDriver } from '@wix/design-system/dist/testkit/unidriver';
import { InputUniDriver as InputUniDriverFactory } from '@wix/design-system/dist/types/Input/Input.uni.driver';
import { UniDriverFactory } from '../../../uniDriverFactory';
import { baseUniDriverFactory } from '../../../../unidriver';

export function ColorEditUniDriver(base: UniDriver, body: UniDriver) {
  const input = (InputUniDriver as UniDriverFactory<InputUniDriverFactory>)(
    base,
    body,
  );

  return {
    ...baseUniDriverFactory(base),
    getValue: () => input.getValue(),
    typeValue: (value: string) => input.enterText(value),
    keyDown: (
      key: string,
      opts?: { shiftKey?: boolean; ctrlKey?: boolean; metaKey?: boolean },
    ) => input.keyDown({ key, ...opts }),
    blur: () => input.blur(),
  };
}
