wix-style-react
Version:
153 lines (132 loc) • 5.09 kB
JavaScript
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _regeneratorRuntime from "@babel/runtime/regenerator";
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
import { baseUniDriverFactory } from '../../test/utils/unidriver';
import inputUniDriverFactory from '../Input/Input.uni.driver.js';
import { colorPickerUniDriverFactory } from '../ColorPicker/ColorPicker.uni.driver.js';
import DATA_HOOKS from './DataHooks';
export var colorInputDriverFactory = function colorInputDriverFactory(base, body) {
var inputTestkit = inputUniDriverFactory(base, body);
var colorPickerTestkit = colorPickerUniDriverFactory(base.$("[data-hook=\"".concat(DATA_HOOKS.COLOR_INPUT_COLOR_PICKER, "\"]")));
return _objectSpread(_objectSpread({}, baseUniDriverFactory(base)), {}, {
/**
* Cancels color selection
* @returns {Promise<Void>}
* */
cancel: function cancel() {
return colorPickerTestkit.cancel();
},
/**
* Confirms color selection
* @returns {Promise<Void>}
* */
confirm: function confirm() {
return colorPickerTestkit.confirm();
},
/**
* Clicks on color viewer box
* @returns {Promise<Void>}
*/
clickColorViewer: function () {
var _clickColorViewer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
return _context.abrupt("return", base.$("[data-hook=\"".concat(DATA_HOOKS.COLOR_INPUT_VIEWER, "\"]")).click());
case 1:
case "end":
return _context.stop();
}
}
}, _callee);
}));
function clickColorViewer() {
return _clickColorViewer.apply(this, arguments);
}
return clickColorViewer;
}(),
/**
* Enters text to color input
* @returns {Promise<Void>}
* */
enterText: function () {
var _enterText = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(text) {
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return inputTestkit.click();
case 2:
_context2.next = 4;
return inputTestkit.enterText(text);
case 4:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
function enterText(_x) {
return _enterText.apply(this, arguments);
}
return enterText;
}(),
/**
* Gets the input value
* @returns {Promise<string>}
* */
getValue: function getValue() {
return inputTestkit.getValue();
},
/**
* Gets the placeholder of the input
* @returns {Promise<string | null>}
* */
getPlaceholder: function getPlaceholder() {
return inputTestkit.getPlaceholder();
},
/**
* Gets the input size
* @returns {Promise<string>}
* */
getSize: function getSize() {
return inputTestkit.getSize();
},
/**
* Checks whether the input is disabled
* @returns {Promise<boolean>}
* */
isDisabled: function isDisabled() {
return inputTestkit.isDisabled();
},
/**
* Checks whether the color picker is visible
* @returns {Promise<boolean>}
* */
colorPickerVisible: function colorPickerVisible() {
return colorPickerTestkit.exists();
},
/**
* Clicks on input
* @returns {Promise<Void>}
* */
click: function click() {
return inputTestkit.click();
},
/**
* Checks whether the given status is displayed
* @returns {Promise<boolean>}
* */
hasStatus: inputTestkit.hasStatus,
/**
* Gets the status message
* @returns {Promise<(string|null)>}
* */
getStatusMessage: inputTestkit.getStatusMessage
});
};
export default colorInputDriverFactory;