UNPKG

wix-style-react

Version:
39 lines 2.25 kB
import { baseUniDriverFactory } from '../test-utils/utils/unidriver'; import { inputWithOptionsUniDriverFactory } from '../InputWithOptions/InputWithOptions.uni.driver'; import { tagPrivateUniDriverFactory } from '../Tag/Tag.private.uni.driver'; export const multiselectUniDriverFactory = (base, body) => { const { driver, inputDriver, dropdownLayoutDriver } = inputWithOptionsUniDriverFactory(base, body); const getInputWrapper = async () => (await driver.inputWrapper()).childNodes[0]; const tags = base.$$('[data-hook="tag"]'); const multiSelectDriver = { ...baseUniDriverFactory(base), ...driver, /** returns the max height of the component */ getMaxHeight: async () => (await getInputWrapper()).style.maxHeight, /** click on the input element wrapper */ clickOnInputWrapper: async () => inputDriver.click(), /** returns true if the input is focused */ inputWrapperHasFocus: () => inputDriver.isFocusedStyle(), /** returns true if the input is disabled */ inputWrapperIsDisabled: async () => !!(await base.$('[data-hook="wsr-custom-input"]')).attr('disabled'), /** returns the number of tags selected in the input */ numberOfTags: () => tags.count(), /** returns the label of the tag given it's index */ getTagLabelAt: index => tags.get(index).text(), /** press the comma key in the input field */ pressCommaKey: () => inputDriver.pressKey(','), /** returns the `tagDriver` for the specified tag id */ getTagDriverByTagId: async (tagId) => tagPrivateUniDriverFactory(tags.filter(async (tag) => (await tag._prop('id')) === tagId).get(0)), /** returns true if a custom suffix exists */ customSuffixExists: async () => !!(await getInputWrapper()).querySelector('[data-hook="custom-suffix"]'), /** returns true if a status indicator exists */ statusIndicatorExists: async () => !!(await getInputWrapper()).querySelector('[data-hook="input-status"]'), }; return { exists: async () => base.exists(), driver: multiSelectDriver, inputDriver, dropdownLayoutDriver, }; }; //# sourceMappingURL=MultiSelect.uni.driver.js.map