@wix/design-system
Version:
@wix/design-system
40 lines • 2.58 kB
JavaScript
import { baseUniDriverFactory } from '../utils/test-utils/unidriver';
import { dataAttr, dataHooks } from './Tag.constants';
import { textUniDriverFactory } from '../Text/Text.uni.driver';
export const tagUniDriverFactory = (base) => {
const removeButton = base.$(`[data-hook="${dataHooks.removeButton}"]`);
const thumb = base.$(`[data-hook="${dataHooks.thumb}"]`);
const textDriver = textUniDriverFactory(base.$(`[data-hook="${dataHooks.text}"]`));
return {
...baseUniDriverFactory(base),
isTiny: async () => (await base.attr(dataAttr.SIZE)) === 'tiny',
isSmall: async () => (await base.attr(dataAttr.SIZE)) === 'small',
isMedium: async () => (await base.attr(dataAttr.SIZE)) === 'medium',
isLarge: async () => (await base.attr(dataAttr.SIZE)) === 'large',
isStandardTheme: async () => (await base.attr(dataAttr.SKIN)) === 'standard',
isWarningTheme: async () => (await base.attr(dataAttr.SKIN)) === 'warning',
isErrorTheme: async () => (await base.attr(dataAttr.SKIN)) === 'error',
isDarkTheme: async () => (await base.attr(dataAttr.SKIN)) === 'dark',
isSuccessTheme: async () => (await base.attr(dataAttr.SKIN)) === 'success',
isStandardSkin: async () => (await base.attr(dataAttr.SKIN)) === 'standard',
isWarningSkin: async () => (await base.attr(dataAttr.SKIN)) === 'warning',
isErrorSkin: async () => (await base.attr(dataAttr.SKIN)) === 'error',
isDarkSkin: async () => (await base.attr(dataAttr.SKIN)) === 'dark',
isSuccessSkin: async () => (await base.attr(dataAttr.SKIN)) === 'success',
isRemovable: async () => removeButton.exists(),
removeTag: async () => removeButton.click(),
click: async () => base.click(),
isThumbExists: () => thumb.exists(),
isDisabled: async () => (await base.attr(dataAttr.DISABLED)) === 'true',
getLabel: async () => base.text(),
getCloseButtonSkin: async () => await removeButton.attr('data-skin'),
getCloseButtonTheme: async () => await removeButton.attr('data-skin'),
getCloseButtonSize: async () => await removeButton.attr('data-size'),
getTextSize: async () => textDriver.getSize(),
getTextWeight: async () => textDriver.getWeight(),
isClickable: async () => (await base.attr(dataAttr.CLICKABLE)) === 'true',
isHoverable: async () => (await base.attr(dataAttr.HOVERABLE)) === 'true',
pressKey: async (key) => removeButton.pressKey(key),
};
};
//# sourceMappingURL=Tag.uni.driver.js.map