UNPKG

@wix/design-system

Version:

@wix/design-system

73 lines 3.03 kB
import { baseUniDriverFactory, findByHookAtIndex, getAllByHook, getByHook, } from '../utils/test-utils/unidriver'; import { dataHooks } from './constants'; const accordionDriverFactory = (base) => ({ ...baseUniDriverFactory(base), // Gets the title by item index getItemTitleAt: (idx) => findByHookAtIndex(base, dataHooks.item, idx) .$('[data-hook="title"]') .text(), // Gets the subtitle by item index getItemSubtitleAt: (idx) => findByHookAtIndex(base, dataHooks.item, idx) .$('[data-hook="accordion-item-subtitle"]') .text(), // Checks whether an icon exist at item index /** * @deprecated * use 'isPrefixExistsAt' instead */ isIconExistsAt: (idx) => findByHookAtIndex(base, dataHooks.item, idx) .$('[data-hook="icon"]') .exists(), // Checks whether prefix exists at item index isPrefixExistsAt: (idx) => findByHookAtIndex(base, dataHooks.item, idx) .$('[data-hook="icon"]') .exists(), // Checks whether suffix exists at item index isSuffixExistsAt: (idx) => findByHookAtIndex(base, dataHooks.item, idx) .$('[data-hook="suffix"]') .exists(), // Checks whether an item is expanded at index isItemExpandedAt: (idx) => findByHookAtIndex(base, dataHooks.item, idx) .$('[data-hook="children"]') .exists(), // Checks whether an item is expanded by title isItemExpandedByTitle: (title) => { const items = getAllByHook(base, dataHooks.item); return items .find(async (item) => { const itemTitle = await getByHook(item, 'title').text(); return itemTitle === title; }) .$('[data-hook="children"]') .exists(); }, // Clicks toggle button at item index clickToggleButtonAt: (idx) => findByHookAtIndex(base, dataHooks.item, idx) .$(`[data-hook="${dataHooks.toggleButton}"]`) .click(), // Clicks item at index clickItemAt: (idx) => findByHookAtIndex(base, dataHooks.item, idx) .$('[data-hook="header"]') .click(), // Clicks item by title clickItemByTitle: (title) => { const items = getAllByHook(base, dataHooks.item); const item = items.find(async (item) => { const itemTitle = await getByHook(item, 'title').text(); return itemTitle === title; }); return getByHook(item, dataHooks.header).click(); }, // Gets toggle button label at item index getToggleButtonLabelAt: (idx) => findByHookAtIndex(base, dataHooks.item, idx) .$(`[data-hook="${dataHooks.toggleButton}"]`) .text(), // Gets transition speed getTransitionSpeed: () => base.attr('data-transition-speed'), // Returns skin getSkin: () => base.attr('data-skin'), // Returns size of horizontal padding getHorizontalPadding: () => base.attr('data-horizontal-padding'), }); export default accordionDriverFactory; //# sourceMappingURL=Accordion.uni.driver.js.map