wix-style-react
Version:
wix-style-react
162 lines (161 loc) • 6.89 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.fieldSetDriverFactory = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _unidriver = require("../test-utils/utils/unidriver");
var _TextUni = require("../Text/Text.uni.driver");
var _InfoIconUni = require("../InfoIcon/InfoIcon.uni.driver");
var _constants = require("./constants");
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; } // @ts-ignore
// @ts-ignore
var fieldSetDriverFactory = (base, body) => {
var getCharactersCounter = /*#__PURE__*/function () {
var _ref = (0, _asyncToGenerator2.default)(function* () {
return yield base.get("[data-hook*=\"".concat(_constants.dataHooks.counter, "\"]"));
});
return function getCharactersCounter() {
return _ref.apply(this, arguments);
};
}();
return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base)), {}, {
/** get legend text */
getLegendText: function () {
var _getLegendText = (0, _asyncToGenerator2.default)(function* () {
var baseUniDriverElement = yield base.get("[data-hook*=\"".concat(_constants.dataHooks.label, "\"]"));
return baseUniDriverElement.text();
});
function getLegendText() {
return _getLegendText.apply(this, arguments);
}
return getLegendText;
}(),
/** returns legend size */
getLegendSize: function () {
var _getLegendSize = (0, _asyncToGenerator2.default)(function* () {
var labelDriver = (0, _TextUni.textUniDriverFactory)(yield base.get("[data-hook=\"".concat(_constants.dataHooks.label, "\"]")));
return labelDriver.getSize();
});
function getLegendSize() {
return _getLegendSize.apply(this, arguments);
}
return getLegendSize;
}(),
/** returns legend placement */
getLegendPlacement: function () {
var _getLegendPlacement = (0, _asyncToGenerator2.default)(function* () {
return yield base.attr('data-legend-placement');
});
function getLegendPlacement() {
return _getLegendPlacement.apply(this, arguments);
}
return getLegendPlacement;
}(),
/** returns legend alignment */
getLegendAlignment: function () {
var _getLegendAlignment = (0, _asyncToGenerator2.default)(function* () {
return yield base.attr('data-legend-alignment');
});
function getLegendAlignment() {
return _getLegendAlignment.apply(this, arguments);
}
return getLegendAlignment;
}(),
/** returns true whether field set is required */
isRequired: function () {
var _isRequired = (0, _asyncToGenerator2.default)(function* () {
return (yield base.get("[data-hook*=\"".concat(_constants.dataHooks.asterisk, "\"]"))).exists();
});
function isRequired() {
return _isRequired.apply(this, arguments);
}
return isRequired;
}(),
/** returns the length left */
getCharCount: function () {
var _getCharCount = (0, _asyncToGenerator2.default)(function* () {
var counter = yield getCharactersCounter();
return parseInt(yield counter.text(), 10);
});
function getCharCount() {
return _getCharCount.apply(this, arguments);
}
return getCharCount;
}(),
/** returns whether the field set length is exceeded */
isLengthExceeded: function () {
var _isLengthExceeded = (0, _asyncToGenerator2.default)(function* () {
var counter = yield getCharactersCounter();
var length = parseInt(yield counter.text(), 10);
return length < 0;
});
function isLengthExceeded() {
return _isLengthExceeded.apply(this, arguments);
}
return isLengthExceeded;
}(),
/** returns tooltip text of the info content */
getInfoContent: function () {
var _getInfoContent = (0, _asyncToGenerator2.default)(function* () {
var testkit = (0, _InfoIconUni.infoIconDriverFactory)(yield base.get("[data-hook=\"".concat(_constants.dataHooks.infoIcon, "\"]")), body);
return testkit.getContent();
});
function getInfoContent() {
return _getInfoContent.apply(this, arguments);
}
return getInfoContent;
}(),
getAlignment: function () {
var _getAlignment = (0, _asyncToGenerator2.default)(function* () {
return yield base.attr('data-alignment');
});
function getAlignment() {
return _getAlignment.apply(this, arguments);
}
return getAlignment;
}(),
getDirection: function () {
var _getDirection = (0, _asyncToGenerator2.default)(function* () {
return yield base.attr('data-direction');
});
function getDirection() {
return _getDirection.apply(this, arguments);
}
return getDirection;
}(),
getGap: function () {
var _getGap = (0, _asyncToGenerator2.default)(function* () {
return yield base.attr('data-gap');
});
function getGap() {
return _getGap.apply(this, arguments);
}
return getGap;
}(),
/** returns status message text */
getStatusMessage: function () {
var _getStatusMessage = (0, _asyncToGenerator2.default)(function* () {
var testkit = (0, _TextUni.textUniDriverFactory)(base.$("[data-hook=\"".concat(_constants.dataHooks.statusMessage, "\"]")));
return testkit.getText();
});
function getStatusMessage() {
return _getStatusMessage.apply(this, arguments);
}
return getStatusMessage;
}(),
/** return true if it has a given status */
hasStatus: function () {
var _hasStatus = (0, _asyncToGenerator2.default)(function* (status) {
return (yield base.attr('data-status')) === status;
});
function hasStatus(_x) {
return _hasStatus.apply(this, arguments);
}
return hasStatus;
}()
});
};
exports.fieldSetDriverFactory = fieldSetDriverFactory;
//# sourceMappingURL=FieldSet.uni.driver.js.map