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

export function NumberEditUniDriver(base: UniDriver, body: UniDriver) {
  const numberInput = (
    NumberInputUniDriver as UniDriverFactory<NumberInputUniDriverFactory>
  )(base, body);

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