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

export function DateTimeEditUniDriver(base: UniDriver, _body: UniDriver) {
  const dateHalf = () => base.$('[data-sub-cell="date"]');
  const timeHalf = () => base.$('[data-sub-cell="time"]');

  return {
    ...baseUniDriverFactory(base),
    getDateInputValue: () => dateHalf().$('input').attr('value'),
    getTimeInputValue: () => timeHalf().$('input').attr('value'),
    clickDateHalf: () => dateHalf().click(),
    clickTimeHalf: () => timeHalf().click(),
    dateHalfHasInput: () => dateHalf().$('input').exists(),
    timeHalfHasInput: () => timeHalf().$('input').exists(),
    hasTimeClearButton: () =>
      timeHalf().$('[data-hook="cell-time-input-clear"]').exists(),
  };
}
