@wix/design-system
Version:
@wix/design-system
56 lines • 1.77 kB
JavaScript
import { baseUniDriverFactory } from '../utils/test-utils/unidriver';
import { dataHooks } from './Radio.constants';
export const radioUniDriverFactory = (base) => {
const byHook = (hook) => base.$(`[data-hook="${hook}"]`);
const getInput = () => byHook(dataHooks.input);
const getIcon = () => byHook(dataHooks.icon);
const getLabel = () => byHook(dataHooks.label);
return {
...baseUniDriverFactory(base),
/**
* Triggers a keyDown event on the radio input.
*/
keyDown: key => getInput().pressKey(key),
/**
* Gets value of radio input.
*/
getValue: () => getInput().attr('value'),
/**
* Gets name of radio input.
*/
getName: () => getInput().attr('name'),
/**
* Gets id of radio input.
*/
getId: () => getInput().attr('id'),
/**
* Gets label text of radio.
*/
getLabel: () => getLabel().text(),
/**
* Checks if icon of radio exists.
*/
iconExists: () => getIcon().exists(),
/**
* Checks if label of radio exists.
*/
labelExists: () => getLabel().exists(),
/**
* Checks if radio is checked.
*/
isChecked: async () => (await base.attr('data-checked')) === 'true',
/**
* Checks if radio is disabled.
*/
isDisabled: async () => (await base.attr('data-disabled')) === 'true',
/**
* Triggers a mouseEnter event.
*/
mouseEnter: () => base.hover(),
/**
* Triggers a mouseLeave event.
*/
mouseLeave: () => base.mouse.leave(),
};
};
//# sourceMappingURL=Radio.uni.driver.js.map