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

export default class MatSlideToggle extends Component {
  constructor(parent) {
      let selector = 'mat-slide-toggle';
      super(parent, selector);
      // https://github.com/angular/components/blob/master/src/material/slide-toggle/slide-toggle.html
  }

  get matMatSlideToggleBar() {
    return this.currentPath + '//div[contains(@class,"mat-slide-toggle-bar")]';
  }

  get toggleInput() {
    return new InputComponent(this.matMatSlideToggleBar);
  }

  async isSelected() {
    return await this.toggleInput.isSelected();
  }

  get thumbContainer() {
    return this.matMatSlideToggleBar + '//div[contains(@class,"mat-slide-toggle-thumb-container")]';
  }

  async select() {
    await (await $(this.thumbContainer)).click();
  }
}
