import { OjSunburstBase } from './OjSunburstBase';

/**
 * The component WebElement for [oj-sunburst](../../jsdocs/oj.ojSunburst.html).
 * Do not instantiate this class directly, instead, use
 * [ojSunburst](../functions/elements.ojSunburst-1.html).
 */
export class OjSunburst extends OjSunburstBase {
  /**
   * Dispatches drill event.
   * @param {string} nodeId  Id of the new node to drill to. Only visible nodes
   * and breadcrumbs are allowed. Any others will throw an exception.
   */
  async doDrill(nodeId: string) {
    let drilling = await this.getDrilling();

    if (drilling === 'on') {
      await this.getDriver().executeScript(
        `
        let sunburst = arguments[0];
        sunburst.getAutomation().dispatchItemDrill(arguments[1]);
      `,
        this,
        nodeId
      );
    }
  }
}
