wix-style-react
Version:
80 lines (67 loc) • 3.44 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 ReactTestUtils from 'react-dom/test-utils';
import { thumbnailDriverFactory as publicDriverFactory } from './Thumbnail.uni.driver';
import { dataHooks } from './constants';
export var thumbnailPrivateDriverFactory = function thumbnailPrivateDriverFactory(base) {
var byHook = function byHook(hook) {
return base.$("[data-hook*=\"".concat(hook, "\"]"));
};
var publicDriver = publicDriverFactory(base);
return _objectSpread(_objectSpread({}, publicDriver), {}, {
/** Does the title exist */
titleExists: function titleExists() {
return byHook(dataHooks.thumbnailTitle).exists();
},
/** Does bottom title exist */
bottomTitleExists: function bottomTitleExists() {
return byHook(dataHooks.thumbnailBottomTitle).exists();
},
/** Does the description exist */
descriptionExists: function descriptionExists() {
return byHook(dataHooks.thumbnailDescription).exists();
},
/** Does the selected icon exist */
selectedIconExists: function selectedIconExists() {
return !!publicDriver.getSelectedIcon();
},
/** Does the thumbnails image exist */
imageExists: function imageExists() {
return byHook(dataHooks.thumbnailImage).exists();
},
/** Does custom child exist */
customChildExists: function customChildExists() {
return byHook('custom-child').exists();
},
keyDown: function () {
var _keyDown = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(keyCode) {
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.t0 = ReactTestUtils.Simulate;
_context.next = 3;
return base.getNative();
case 3:
_context.t1 = _context.sent;
_context.t2 = {
keyCode: keyCode
};
return _context.abrupt("return", _context.t0.keyDown.call(_context.t0, _context.t1, _context.t2));
case 6:
case "end":
return _context.stop();
}
}
}, _callee);
}));
function keyDown(_x) {
return _keyDown.apply(this, arguments);
}
return keyDown;
}()
});
};