@wix/design-system
Version:
@wix/design-system
35 lines • 1.29 kB
JavaScript
import { baseUniDriverFactory } from '../utils/test-utils/unidriver';
import { dataHooks } from './HorizontalScroll.constants';
export const horizontalScrollDriverFactory = (base) => {
const getElementByHook = (hook) => base.$(`[data-hook="${hook}"]`);
const leftButton = getElementByHook(dataHooks.leftButton);
const rightButton = getElementByHook(dataHooks.rightButton);
const scrollContainer = getElementByHook(dataHooks.scrollContainer);
return {
...baseUniDriverFactory(base),
/**
* Checks if left button exists.
*/
leftButtonExists: () => leftButton.exists(),
/**
* Checks if right button exists.
*/
rightButtonExists: () => rightButton.exists(),
/**
* Clicks left button.
*/
clickLeftButton: () => leftButton.click(),
/**
* Clicks right button.
*/
clickRightButton: () => rightButton.click(),
/**
* Retrieves scrollLeft property of the scrollable container.
*/
getScrollPosition: async () => {
const nativeElement = await scrollContainer.getNative();
return nativeElement.scrollLeft;
},
};
};
//# sourceMappingURL=HorizontalScroll.uni.driver.js.map