import { it } from '@jest/globals';
import { newSpecPage } from '@stencil/core/testing';
/**
 * Check that boolean prop will add CSS class
 */
const isClassToggled = async (parameters) => {
  const { component, className, propName, tagName, testId } = parameters;
  it(`adds class ${className} when prop ${propName} is set`, async () => {
    // Render whole component
    const page = await newSpecPage({
      components: [component],
      html: `<${tagName}></${tagName}>`,
    });
    // Find element, which we are goingto examine
    const element = page.root.shadowRoot.querySelector(`[data-testid="${testId}"]`);
    // Check that class is not set already
    expect(element).not.toHaveClass(className);
    // Set prop
    page.root.setAttribute(propName, null);
    await page.waitForChanges();
    // Check that class is not set already
    expect(element).toHaveClass(className);
  });
};
export default isClassToggled;
