import Component from '../../component.js';

export default class CoUxFormControlCheckbox extends Component {

    constructor(parent) {
        let selector = 'input[@data-e2e = "ux-form-control-cb-rw"]';
        super(parent, selector);
        //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/src/lib/ux-components/ux-form-control/ux-form-control.component.html
    }
    get checkBoxLabel() {
        return this.currentPath + '/ancestor-or-self::ux-form-control[1]/label';
    }
    async isCheckBoxDisabled() {
        let at = await (await $(this.currentPath)).getAttribute('Disabled');
        if ( at === 'true' ) {
            return true;
        } else if (at === null) {
            return false;
        } else { throw new Error(
            'ux-form-control <isCheckBoxDisabled> method needs to be revised!');
        }
    }
    async isSelected() {
        return await (await $(this.currentPath)).isSelected();
    }
}


