@wix/design-system
Version:
@wix/design-system
40 lines • 1.45 kB
JavaScript
import { baseUniDriverFactory, isElementFocused, } from '../utils/test-utils/unidriver';
import { DATA_HOOKS } from './ClickableCard.constants';
export const clickableCardDriverFactory = (base) => {
const getElementByHook = (hook) => base.$(`[data-hook="${hook}"]`);
const clickableOverlay = getElementByHook(DATA_HOOKS.clickableOverlay);
return {
...baseUniDriverFactory(base),
/**
* Checks if the card is focused.
*/
isFocused: async () => await isElementFocused(clickableOverlay),
/**
* Checks if the card is disabled.
*/
isDisabled: async () => {
const disabledAttr = await clickableOverlay.attr('disabled');
return disabledAttr !== null;
},
/**
* Checks if the card's 'aria-disabled' attribute is set to true.
*/
isAriaDisabled: async () => {
const disabledAttr = await clickableOverlay.attr('aria-disabled');
return disabledAttr === 'true';
},
/**
* Focuses the card.
*/
focus: async () => (await clickableOverlay.getNative()).focus(),
/**
* Blurs the card.
*/
blur: async () => (await clickableOverlay.getNative()).blur(),
/**
* Clicks on the card.
*/
click: () => clickableOverlay.click(),
};
};
//# sourceMappingURL=ClickableCard.uni.driver.js.map