UNPKG

@wix/design-system

Version:

@wix/design-system

74 lines 2.96 kB
import { baseUniDriverFactory, findByHook, } from '../utils/test-utils/unidriver'; import { dataHooks } from './CornerRadiusInput.constants'; import { numberInputDriverFactory } from '../NumberInput/NumberInput.uni.driver'; import { toggleButtonDriverFactory } from '../ToggleButton/ToggleButton.uni.driver'; import { liveRegionDriverFactory } from '../LiveRegion/LiveRegion.uni.driver'; const linkingButtonDriver = async (base, body) => { const linkingButtonBase = findByHook(base, dataHooks.autoScaleButton); const { isButtonSelected, click, exists, element, getLabelValue } = toggleButtonDriverFactory(linkingButtonBase, body); return { click, exists, element, isButtonSelected, getLabelValue, }; }; const cornerInputDriver = async (corner, base, body) => { const cornerToHook = { topLeft: dataHooks.topLeft, topRight: dataHooks.topRight, bottomLeft: dataHooks.bottomLeft, bottomRight: dataHooks.bottomRight, }; const inputBase = findByHook(base, cornerToHook[corner]); const { enterText, getAriaLabel, getValue, hasStatus, getSize, getCustomAffixText, } = numberInputDriverFactory(inputBase, body); return { ...baseUniDriverFactory(inputBase), /** Checks if input has provided status */ hasStatus, /** Focuses input element */ enterText, /** Returns aria label */ getAriaLabel, /** Returns input value */ getValue, /** Returns if the element is currently focused */ getSize, /** Returns the suffix text */ getSuffixText: getCustomAffixText, }; }; export const cornerRadiusInputDriverFactory = (base, body) => { return { ...baseUniDriverFactory(base), /** returns if linking functionality is enabled */ isLinked: async () => { const linkingButton = await linkingButtonDriver(base, body); return linkingButton.isButtonSelected(); }, /** returns the size of component */ getSize: async () => { // same size applied to all corners const topLeft = await cornerInputDriver('topLeft', base, body); return topLeft.getSize(); }, /** * Returns the testkit of the input of the specified corner */ getCornerInput: async (corner) => { return cornerInputDriver(corner, base, body); }, /** * Returns linking button testkit */ getLinkingButton: async () => linkingButtonDriver(base, body), getLinkedValuesChangedMessage: async () => { const { getMessage } = liveRegionDriverFactory(findByHook(base, dataHooks.liveRegion)); return getMessage(); }, }; }; export { cornerInputDriver, linkingButtonDriver }; export default cornerRadiusInputDriverFactory; //# sourceMappingURL=CornerRadiusInput.uni.driver.js.map