wix-style-react
Version:
wix-style-react
137 lines (117 loc) • 5.65 kB
JavaScript
var _this = this;
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
import tooltipDriverFactory from '../Tooltip/Tooltip.puppeteer.driver.js';
var formFieldDriverFactory = function () {
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(component, page) {
return regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
return _context4.abrupt('return', {
element: function element() {
return component;
},
getLabelValue: function () {
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
var label;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return component.$('[data-hook="formfield-label"]');
case 2:
label = _context.sent;
return _context.abrupt('return', page.evaluate(function (_label) {
return _label.querySelector('label').innerText;
}, label));
case 4:
case 'end':
return _context.stop();
}
}
}, _callee, _this);
}));
return function getLabelValue() {
return _ref2.apply(this, arguments);
};
}(),
getTooltipInfoValue: function () {
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(delay) {
var infoIcon, tooltip, tooltipContent;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return component.$('[data-hook="formfield-infoicon"]');
case 2:
infoIcon = _context2.sent;
_context2.next = 5;
return infoIcon.hover();
case 5:
_context2.t0 = tooltipDriverFactory;
_context2.next = 8;
return page.$('[data-hook="formfield-infotooltip"]');
case 8:
_context2.t1 = _context2.sent;
_context2.t2 = page;
_context2.next = 12;
return (0, _context2.t0)(_context2.t1, _context2.t2);
case 12:
tooltip = _context2.sent;
_context2.next = 15;
return tooltip.getTooltipTextContent(delay);
case 15:
tooltipContent = _context2.sent;
_context2.next = 18;
return page.mouse.move(0, 0);
case 18:
return _context2.abrupt('return', tooltipContent);
case 19:
case 'end':
return _context2.stop();
}
}
}, _callee2, _this);
}));
return function getTooltipInfoValue(_x3) {
return _ref3.apply(this, arguments);
};
}(),
isRequired: function () {
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
return regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.t0 = Boolean;
_context3.next = 3;
return component.$('[data-hook="formfield-asterisk"]');
case 3:
_context3.t1 = _context3.sent;
return _context3.abrupt('return', (0, _context3.t0)(_context3.t1));
case 5:
case 'end':
return _context3.stop();
}
}
}, _callee3, _this);
}));
return function isRequired() {
return _ref4.apply(this, arguments);
};
}()
});
case 1:
case 'end':
return _context4.stop();
}
}
}, _callee4, _this);
}));
return function formFieldDriverFactory(_x, _x2) {
return _ref.apply(this, arguments);
};
}();
export default formFieldDriverFactory;