UNPKG

wix-style-react

Version:
44 lines 1.82 kB
import { baseUniDriverFactory, findByHook, } from '../test-utils/utils/unidriver'; import { calendarUniDriverFactory } from '../Calendar/Calendar.uni.driver.js'; import { testkit as inputUniDriverFactory } from '../Input/Input.uni.driver.js'; import { popoverUniDriverFactory } from '../Popover/Popover.uni.driver'; import { dataHooks } from './constants'; export const datePickerUniDriverFactory = (base, body) => { const calendarDriver = calendarUniDriverFactory(findByHook(base, dataHooks.datePickerCalendar), body); const inputDriver = inputUniDriverFactory(findByHook(base, dataHooks.datePickerInput), body); const popoverDriver = popoverUniDriverFactory(findByHook(base, dataHooks.datePickerPopover), body); const driver = { exists: () => baseUniDriverFactory(base).exists(), open: async () => { await inputDriver.click(); await inputDriver.trigger('keyDown', { key: 'ArrowUp', keyCode: 38, }); }, getWidth: () => base._prop('style').then(style => style.width), clickOutside: () => popoverDriver.clickOutside(), focusCalendar: () => inputDriver.trigger('keyDown', { key: 'ArrowUp', keyCode: 38 }), }; // TODO: needs to be fixed, autodocs doesn't generate the docs below. return { /** * Input Unidriver methods */ inputDriver, /** * Calender Unidriver methods */ calendarDriver, /** * Checks whether the component found with the given data hook. * @returns {Promise<boolean>} */ exists: driver.exists, /** * Contains 'exists', 'open' and 'getWidth' methods */ driver, }; }; //# sourceMappingURL=DatePicker.uni.driver.js.map