wix-style-react
Version:
69 lines (61 loc) • 2.15 kB
JavaScript
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import { baseUniDriverFactory, findByHook } from '../../test/utils/unidriver';
import { calendarUniDriverFactory } from '../Calendar/Calendar.uni.driver.js';
import { testkit as inputUniDriverFactory } from '../Input/Input.uni.driver.js';
import { dataHooks } from './constants';
export var datePickerUniDriverFactory = function datePickerUniDriverFactory(base, body) {
var calendarDriver = calendarUniDriverFactory(findByHook(base, dataHooks.datePickerCalendar), body);
var inputDriver = inputUniDriverFactory(findByHook(base, dataHooks.datePickerInput), body);
var driver = {
exists: function exists() {
return baseUniDriverFactory(base).exists();
},
open: function () {
var _open = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return inputDriver.click();
case 2:
return _context.abrupt("return", _context.sent);
case 3:
case "end":
return _context.stop();
}
}
}, _callee);
}));
function open() {
return _open.apply(this, arguments);
}
return open;
}(),
getWidth: function getWidth() {
return base._prop('style').then(function (style) {
return style.width;
});
}
}; // TODO: needs to be fixed, autodocs doesn't generate the docs below.
return {
/**
* Input Unidriver methods
*/
inputDriver: inputDriver,
/**
* Calender Unidriver methods
*/
calendarDriver: calendarDriver,
/**
* Checks whether the component found with the given data hook.
* @returns {Promise<boolean>}
*/
exists: driver.exists,
/**
* Contains 'exists', 'open' and 'getWidth' methods
*/
driver: driver
};
};