wix-style-react
Version:
wix-style-react
27 lines • 1.29 kB
JavaScript
import { baseUniDriverFactory } from '../../test-utils/utils/unidriver';
import { dataHooks } from './constants';
export const toggleSwitchUniDriverFactory = (base) => {
const byDataHook = (dataHook) => `[data-hook="${dataHook}"]`;
const knob = base.$(byDataHook(dataHooks.knob));
const knobIcon = base.$(byDataHook(dataHooks.knobIcon));
const checkbox = base.$(byDataHook(dataHooks.toggleSwitchInput));
const track = base.$(byDataHook(dataHooks.track));
const isDisabled = async () => (await base.attr('data-disabled')) === 'true';
const getKnobIcon = () => knobIcon.getNative();
return {
...baseUniDriverFactory(base),
// @ts-ignore
click: async () => !(await isDisabled()) && checkbox.click(),
isDisabled,
isChecked: () => checkbox._prop('checked'),
getKnobIcon,
hasKnobIcon: async () => !!(await getKnobIcon()).innerHTML,
getId: () => checkbox._prop('id'),
getTabIndex: () => checkbox._prop('tabIndex'),
getRootStyles: () => base._prop('style'),
getTrackStyles: () => track._prop('style'),
getKnobStyles: () => knob._prop('style'),
getKnobIconStyles: () => knobIcon._prop('style'),
};
};
//# sourceMappingURL=ToggleSwitchCore.uni.driver.js.map