@wix/design-system
Version:
@wix/design-system
30 lines • 1.41 kB
JavaScript
import ReactTestUtils from 'react-dom/test-utils';
import { DATA_HOOKS } from './constants';
import deprecationTestkitLog from '../utils/deprecationTestkitLog';
export const carouselWIPDriverFactory = ({ element }) => {
deprecationTestkitLog('carouselWIPDriverFactory legacy testkit is deprecated and will be removed in next major release. Please use carouselWIPUniDriverFactory from CarouselWIP.uni.driver instead.');
return {
exists: () => !!element,
isLoading: () => {
const loader = element.querySelector(`[data-hook="${DATA_HOOKS.loader}"]`);
return !!loader;
},
getChildren: () => element.querySelectorAll(`[data-hook="${DATA_HOOKS.child}"]`),
getImages: () => {
return Array.from(element.querySelectorAll(`[data-hook="${DATA_HOOKS.carouselImage}"]`)).map((img) => img.src);
},
clickPrevious: () => {
const prevButton = element.querySelector(`[data-hook="${DATA_HOOKS.prevButton}"]`);
if (prevButton) {
ReactTestUtils.Simulate.click(prevButton);
}
},
clickNext: () => {
const nextButton = element.querySelector(`[data-hook="${DATA_HOOKS.nextButton}"]`);
if (nextButton) {
ReactTestUtils.Simulate.click(nextButton);
}
},
};
};
//# sourceMappingURL=CarouselWIP.driver.js.map