@wix/design-system
Version:
@wix/design-system
37 lines • 2.18 kB
JavaScript
import { baseUniDriverFactory } from '../utils/test-utils/unidriver';
import { dataHooks, SKINS, TYPE_POSITIONS_MAP } from './constants';
export const notificationUniDriverFactory = base => {
const getElementByDataHook = dataHook => base.$(`[data-hook="${dataHook}"]`);
const notificationContent = getElementByDataHook(dataHooks.notificationContent);
const labelText = getElementByDataHook(dataHooks.notificationLabel);
const actionButton = getElementByDataHook(dataHooks.notificationCtaButton);
const closeButton = getElementByDataHook(dataHooks.notificationCloseButton);
const getSkin = async () => await base.attr('data-skin');
const getType = async () => await base.attr('data-type');
return {
...baseUniDriverFactory(base),
visible: () => notificationContent.exists(),
/** @deprecated use hasSkin with skin prop instead */
hasTheme: async () => !!(await getSkin()),
hasSkin: async () => !!(await getSkin()),
isStandardNotification: async () => (await getSkin()) === SKINS.standard,
isErrorNotification: async () => (await getSkin()) === SKINS.error,
isSuccessNotification: async () => (await getSkin()) === SKINS.success,
isWarningNotification: async () => (await getSkin()) === SKINS.warning,
isPremiumNotification: async () => (await getSkin()) === SKINS.premium,
getLabelText: () => labelText.text(),
hasActionButton: () => actionButton.exists(),
getActionButtonText: () => actionButton.text(),
hasCloseButton: () => closeButton.exists(),
isRelativelyPositioned: async () => (await getType()) === TYPE_POSITIONS_MAP.relative,
isFixedPositioned: async () => (await getType()) === TYPE_POSITIONS_MAP.fixed,
isAbsolutePositioned: async () => (await getType()) === TYPE_POSITIONS_MAP.absolute,
clickOnCloseButton: () => closeButton.click(),
clickOnActionButton: () => actionButton.click(),
getZIndex: async () => {
const style = await base._prop('style');
return Number(style['z-index']);
},
};
};
//# sourceMappingURL=Notification.uni.driver.js.map