import { it } from '@jest/globals';
import { newSpecPage } from '@stencil/core/testing';
/**
 * Check that component has settable Tracking ID
 */
const hasTrackingId = async (component, tagName) => {
  it(`has settable dataTrackingId`, async () => {
    // Render component
    const page = await newSpecPage({
      components: [component],
      html: `<${tagName} ${tagName === 'telia-heading' ? 'tag="h1"' : ''} ${tagName === 'telia-fieldset' ? 'legend="legend"' : ''}></${tagName}>`,
    });
    // Get first element
    const element = page.root;
    // Get telia-vst element
    const teliaVst = element.shadowRoot != null
      ? await element.shadowRoot.querySelector('telia-vst')
      : await element.querySelector('telia-vst');
    // Get telia-vst dataTrackingId attribute
    const attrValues = teliaVst.getAttribute('dataTrackingId');
    expect(attrValues).toBe(tagName);
  });
};
export default hasTrackingId;
