wix-style-react
Version:
wix-style-react
58 lines (57 loc) • 2.32 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _testUtils = _interopRequireDefault(require("react-dom/test-utils"));
var _InputWithOptions = _interopRequireDefault(require("../InputWithOptions/InputWithOptions.driver"));
var _Tag = _interopRequireDefault(require("../Tag/Tag.driver"));
var multiSelectDriverFactory = _ref => {
var {
element,
wrapper,
eventTrigger
} = _ref;
var {
driver,
inputDriver,
dropdownLayoutDriver
} = (0, _InputWithOptions.default)({
element,
wrapper,
eventTrigger
});
var inputWrapper = driver.inputWrapper();
var tags = [...inputWrapper.querySelectorAll('[data-hook="tag"]')];
var multiSelectDriver = Object.assign(driver, {
/** returns the max height of the component */
getMaxHeight: () => inputWrapper.style.maxHeight,
/** click on the input element wrapper */
clickOnInputWrapper: () => _testUtils.default.Simulate.click(inputWrapper),
/** returns true if the input is focused */
inputWrapperHasFocus: () => inputDriver.isFocusedStyle(),
/** returns true if the input is disabled */
inputWrapperIsDisabled: () => inputWrapper.querySelector('[data-hook="wsr-custom-input"]').hasAttribute('disabled'),
/** returns the number of tags selected in the input */
numberOfTags: () => tags.length,
/** returns true if a custom suffix exists */
customSuffixExists: () => !!inputWrapper.querySelector('[data-hook="custom-suffix"]'),
/** returns true if a status indicator exists */
statusIndicatorExists: () => !!inputWrapper.querySelector('[data-hook="input-status"]'),
/** returns the label of the tag given it's index */
getTagLabelAt: index => tags[index].textContent,
/** press the comma key in the input field */
pressCommaKey: () => inputDriver.keyDown(','),
/** returns the `tagDriver` for the specified tag id */
getTagDriverByTagId: tagId => (0, _Tag.default)({
element: tags.find(tag => tag.id === tagId)
})
});
return {
exists: () => !!element,
driver: multiSelectDriver,
inputDriver,
dropdownLayoutDriver
};
};
var _default = exports.default = multiSelectDriverFactory;
//# sourceMappingURL=MultiSelect.driver.js.map