import Component  from '../component.js'

export default class CoUxSwitch extends Component {
    constructor(parent) {
      let selector = 'ux-switch';
      super(parent, selector);
    }

    get dataE2E() {
      let path = '//*[@data-e2e = "ux-switch"]';
      return this.currentPath + path;
    }

    get switchHandle() {
      let path = '//*[@class = "ux-c-switch__handle"]';
      return this.dataE2E + path;
    }
   async isChecked() {
      let cl = await (await $(this.dataE2E)).getAttribute('aria-checked');
      if (cl === 'true') {
         return true;
      } else if (cl === 'false') {
         return false;
      } else {
         throw new Error('Ux-Switch component object needs to be revised, ' +
         '<is Checked> is missing the aria-checked attribute or value is not known.');
      }
    }
   async isDisabled() {
      let cl = await (await $(this.dataE2E)).getAttribute('aria-disabled');
      if (cl === 'true') {
         return true;
      } else if (cl === 'false') {
         return false;
      } else {
         throw new Error('Ux-Switch component object needs to be revised, ' +
         '<is Disabled> is missing the aria-disabled attribute or value is not known.');
      }
    }
   async isSmall() {
      let cl = await (await $(this.dataE2E)).getAttribute('class');
      if (cl.includes('ux-c-switch--small')) {
         return true;
      } else {
         return false;
      }
    }
   async isLarge() {
      let cl = await(await $(this.dataE2E)).getAttribute('class');
      if (cl.includes('ux-c-switch--large')) {
         return true;
      } else {
         return false;
      }
    }
}


