UNPKG

@wix/design-system

Version:

@wix/design-system

83 lines 3.06 kB
import { baseUniDriverFactory, findByHook, } from '../utils/test-utils/unidriver'; import { buttonDriverFactory } from '../Button/Button.uni.driver'; import { SKIN, dataHooks } from './constants'; export const sectionHelperUniDriverFactory = (base) => { const actionButtonDriver = () => buttonDriverFactory(base.$(`[data-hook="${dataHooks.actionButton}"]`)); const closeButtonDriver = () => buttonDriverFactory(base.$(`[data-hook="${dataHooks.closeButton}"]`)); const hasSkin = async (skin) => (await base.attr('data-skin')) === skin; const getPrefix = () => findByHook(base, dataHooks.prefix); return { ...baseUniDriverFactory(base), /** * Gets the title text * @return {Promise<string>} */ titleText: () => base.$(`[data-hook="${dataHooks.title}"]`).text(), /** * Gets the action text * @return {Promise<string>} */ actionText: () => actionButtonDriver().getButtonTextContent(), /** * Clicks the action * @return {Promise<void>} */ clickAction: () => actionButtonDriver().click(), /** * Clicks the close button * @return {Promise<void>} */ clickClose: () => closeButtonDriver().click(), /** * Checks whether the close button is displayed * @return {Promise<boolean>} */ isCloseButtonDisplayed: () => closeButtonDriver().exists(), /** * Checks whether the prefix is displayed * @return {Promise<boolean>} */ hasPrefix: async () => getPrefix().exists(), /** * Gets the text content * @return {Promise<string>} */ textContent: () => base.text(), /** * Checks whether the component appears as "warning" * @return {Promise<boolean>} */ isWarning: () => hasSkin(SKIN.Warning), /** * Checks whether the component appears as "standard" * @return {Promise<boolean>} */ isStandard: () => hasSkin(SKIN.Standard), /** * Checks whether the component appears as "danger" * @return {Promise<boolean>} */ isDanger: () => hasSkin(SKIN.Danger), /** * Checks whether the component appears as "experimentalDark" * @return {Promise<boolean>} */ isExperimentalDark: () => hasSkin(SKIN.ExperimentalDark), /** * Checks whether the component appears as "success" * @return {Promise<boolean>} */ isSuccess: () => hasSkin(SKIN.Success), /** * Checks whether the component appears as "premium" * @return {Promise<boolean>} */ isPremium: () => hasSkin(SKIN.Premium), /** * Checks whether the component appears as "preview" * @return {Promise<boolean>} */ isPreview: () => hasSkin(SKIN.Preview), }; }; //# sourceMappingURL=SectionHelper.uni.driver.js.map