import Component  from '../component.js'

export default class CoEuiIconSvg extends Component {
  constructor(parent) {
    let selector = '*[self::span[euiIconSvg] or self::i[euiIconSvg] or self::eui-icon-svg]';
    super(parent, selector);
    // https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/atoms/eui-icon/eui-icon-svg.component.html?at=support%2F13.x
  }
  async isDefault() {
    return await (await $(this.currentPath + '/self::*[@icon]')).isExisting();
  }
  async isCustom() {
    return await (await $(this.currentPath + '/self::*[@iconUrl]')).isExisting();
  }

  //following elements are present in the template but SVG element doesn’t support the standard format of XPath, hence these elements cannot be used in the tests
  get defaultSvg() {
    return this.currentPath + '//svg//use/ancestor::svg';
  }
  get defaultSvgUse() {
    return this.defaultSvg + '//use'
  }
  get customSvg() {
    return this.currentPath + '//svg//image/ancestor::svg';
  }
  get customSvgImage() {
    return this.customSvg + '//image';
  }
}


