UNPKG

wix-style-react

Version:
123 lines (122 loc) 5.85 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); exports.__esModule = true; exports.default = exports.colorInputPrivateDriverFactory = void 0; var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); var _ColorInputUni = require("./ColorInput.uni.driver"); var _SwatchesPrivateUni = require("../Swatches/test/Swatches.private.uni.driver"); var _DataHooks = _interopRequireDefault(require("./DataHooks")); var _InputUni = _interopRequireDefault(require("../Input/Input.uni.driver")); var _PopoverUni = require("../Popover/Popover.uni.driver"); function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } var colorInputPrivateDriverFactory = (base, body) => { var swatchesHook = "[data-hook=\"".concat(_DataHooks.default.COLOR_PICKER_SWATCHES, "\"]"); var swatchesDriver = (0, _SwatchesPrivateUni.swatchesPrivateDriverFactory)(base.$(swatchesHook)); var colorViewerPopoverHook = "[data-hook=\"".concat(_DataHooks.default.COLOR_INPUT_POPOVER, "\"]"); var colorViewerPopoverTestkit = (0, _PopoverUni.popoverUniDriverFactory)(base.$(colorViewerPopoverHook), body); var isHashDisabled = /*#__PURE__*/function () { var _ref = (0, _asyncToGenerator2.default)(function* () { return (yield base.$("[data-hook=\"".concat(_DataHooks.default.COLOR_INPUT_HASH, "\"]")).attr('data-disabled')) === 'true'; }); return function isHashDisabled() { return _ref.apply(this, arguments); }; }(); var getViewerSize = () => base.$("[data-hook=\"".concat(_DataHooks.default.COLOR_INPUT_VIEWER, "\"]")).attr('data-size'); var inputTestkit = (0, _InputUni.default)(base); return _objectSpread(_objectSpread({}, (0, _ColorInputUni.colorInputDriverFactory)(base, body)), {}, { isHashDisabled, isViewerNull: function () { var _isViewerNull = (0, _asyncToGenerator2.default)(function* () { return yield base.$("[data-hook=\"".concat(_DataHooks.default.COLOR_INPUT_VIEWER_LINE, "\"]")).exists(); }); function isViewerNull() { return _isViewerNull.apply(this, arguments); } return isViewerNull; }(), getViewerSize, getSwatch: function () { var _getSwatch = (0, _asyncToGenerator2.default)(function* (index) { return swatchesDriver.getSwatch(index); }); function getSwatch(_x) { return _getSwatch.apply(this, arguments); } return getSwatch; }(), getSwatchCount: function () { var _getSwatchCount = (0, _asyncToGenerator2.default)(function* () { return swatchesDriver.getSwatchCount(); }); function getSwatchCount() { return _getSwatchCount.apply(this, arguments); } return getSwatchCount; }(), /** Private Swatches driver function to test if swatch is transparent at given index */ isSwatchTransparentAt: function () { var _isSwatchTransparentAt = (0, _asyncToGenerator2.default)(function* (index) { return swatchesDriver.isSwatchTransparentAt(index); }); function isSwatchTransparentAt(_x2) { return _isSwatchTransparentAt.apply(this, arguments); } return isSwatchTransparentAt; }(), keyDown: function () { var _keyDown = (0, _asyncToGenerator2.default)(function* (event) { if (typeof event === 'string') { yield inputTestkit.keyDown({ key: event }); } else { yield inputTestkit.keyDown(event); } }); function keyDown(_x3) { return _keyDown.apply(this, arguments); } return keyDown; }(), blur: inputTestkit.blur, focus: inputTestkit.focus, clickOutside: function () { var _clickOutside = (0, _asyncToGenerator2.default)(function* () { return colorViewerPopoverTestkit.clickOutside(); }); function clickOutside() { return _clickOutside.apply(this, arguments); } return clickOutside; }(), hasPrefix: inputTestkit.hasPrefix, // TODO: this is because of a bug - clicking on ColorInput input field triggers onConfirm // introducing private drivers with focus() instead of click() so our tests would't break // remove this and use public unidriver once https://wix.monday.com/boards/2436042988/pulses/5145825887 is fixed click: function () { var _click = (0, _asyncToGenerator2.default)(function* () { return inputTestkit.focus(); }); function click() { return _click.apply(this, arguments); } return click; }(), enterText: function () { var _enterText = (0, _asyncToGenerator2.default)(function* (text) { yield inputTestkit.focus(); yield inputTestkit.enterText(text); }); function enterText(_x4) { return _enterText.apply(this, arguments); } return enterText; }() }); }; exports.colorInputPrivateDriverFactory = colorInputPrivateDriverFactory; var _default = exports.default = colorInputPrivateDriverFactory; //# sourceMappingURL=ColorInput.private.uni.driver.js.map