UNPKG

@wix/design-system

Version:

@wix/design-system

30 lines 1.35 kB
import ReactTestUtils from 'react-dom/test-utils'; import { SKIN } from './constants'; const sectionHelperDriverFactory = ({ element }) => { const hasSkin = skin => element.dataset.skin === skin; const byHook = hook => element.querySelector(`[data-hook="${hook}"]`); const getCloseButton = () => byHook('sectionhelper-close-btn'); const getActionButton = () => byHook('sectionhelper-action-btn'); return { exists: () => !!element, titleText: () => byHook('sectionhelper-title').textContent, actionText: () => getActionButton().textContent, clickAction: () => { ReactTestUtils.Simulate.click(getActionButton()); }, clickClose: () => { ReactTestUtils.Simulate.click(getCloseButton()); }, isCloseButtonDisplayed: () => !!getCloseButton(), textContent: () => element.textContent, isWarning: () => hasSkin(SKIN.Warning), isStandard: () => hasSkin(SKIN.Standard), isDanger: () => hasSkin(SKIN.Danger), isExperimentalDark: () => hasSkin(SKIN.ExperimentalDark), isSuccess: () => hasSkin(SKIN.Success), isPremium: () => hasSkin(SKIN.Premium), isPreview: () => hasSkin(SKIN.Preview), }; }; export default sectionHelperDriverFactory; //# sourceMappingURL=SectionHelper.driver.js.map