wix-style-react
Version:
31 lines • 1.27 kB
JavaScript
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
import ReactTestUtils from 'react-dom/test-utils';
import { DATA_HOOKS } from './constants';
export var carouselWIPDriverFactory = function carouselWIPDriverFactory(_ref) {
var element = _ref.element;
return {
exists: function exists() {
return !!element;
},
isLoading: function isLoading() {
var loader = element.querySelector("[data-hook=\"".concat(DATA_HOOKS.loader, "\"]"));
return !!loader;
},
getChildren: function getChildren() {
return element.querySelectorAll("[data-hook=\"".concat(DATA_HOOKS.child, "\"]"));
},
getImages: function getImages() {
return _toConsumableArray(element.querySelectorAll("[data-hook=\"".concat(DATA_HOOKS.carouselImage, "\"]"))).map(function (img) {
return img.src;
});
},
clickPrevious: function clickPrevious() {
var prevButton = element.querySelector("[data-hook=\"".concat(DATA_HOOKS.prevButton, "\"]"));
ReactTestUtils.Simulate.click(prevButton);
},
clickNext: function clickNext() {
var nextButton = element.querySelector("[data-hook=\"".concat(DATA_HOOKS.nextButton, "\"]"));
ReactTestUtils.Simulate.click(nextButton);
}
};
};