import { newSpecPage } from '@stencil/core/testing';
import { BsRadio } from '../bs-radio';
import { faker } from '@faker-js/faker';
const id = faker.datatype.uuid();
const name = faker.random.word();
const label = faker.random.word();
describe('bs-radio', () => {
  it('passes expected attributes', async () => {
    const page = await newSpecPage({
      components: [BsRadio],
      html: `<bs-radio
        input-id="${id}"
        name="${name}"
        form="asdf"
      ></bs-radio>`,
    });
    let component = page.root;
    let input = component.querySelector('input');
    expect(input.getAttribute('id')).toBe(id);
    expect(input.getAttribute('name')).toBe(name);
  });
  it('handles error prop', async () => {
    const page = await newSpecPage({
      components: [BsRadio],
      html: `<bs-radio error="true"></bs-radio>`,
    });
    const component = page.root;
    const input = component.querySelector('input');
    expect(input).toHaveAttribute('data-error');
    component.error = false;
    await page.waitForChanges();
    expect(input).not.toHaveAttribute('data-error');
  });
  it('handles disabled prop', async () => {
    const page = await newSpecPage({
      components: [BsRadio],
      html: `<bs-radio disabled="true"></bs-radio>`,
    });
    const component = page.root;
    const input = component.querySelector('input');
    expect(input).toHaveAttribute('disabled');
    component.disabled = false;
    await page.waitForChanges();
    expect(input).not.toHaveAttribute('disabled');
    component.disabled = undefined;
    await page.waitForChanges();
    expect(input).not.toHaveAttribute('disabled');
  });
  it('handles size prop by passing value to bs-radio data-size attr', async () => {
    const size = 'sm';
    const page = await newSpecPage({
      components: [BsRadio],
      html: `<bs-radio size='${size}'></bs-radio>`,
    });
    const component = page.root;
    expect(component.getAttribute('data-size')).toBe(size);
  });
  it('sets disabled state on checkbox if given prop', async () => {
    const page = await newSpecPage({
      components: [BsRadio],
      html: `<bs-radio disabled="true" label="${label}"></bs-radio>`,
    });
    const component = page.root;
    const inputEl = component.querySelector('input');
    expect(inputEl).toHaveAttribute('disabled');
    component.disabled = false;
    await page.waitForChanges();
    expect(inputEl).not.toHaveAttribute('disabled');
  });
  it('sets data-disabled attribute on label if given prop', async () => {
    const page = await newSpecPage({
      components: [BsRadio],
      html: `<bs-radio disabled="true" label="${label}"></bs-radio>`,
    });
    const component = page.root;
    const bsLabel = component.querySelector('bs-label');
    expect(bsLabel).toHaveAttribute('disabled');
    component.disabled = false;
    await page.waitForChanges();
    expect(bsLabel).not.toHaveAttribute('disabled');
  });
});
//# sourceMappingURL=bs-radio.spec.js.map
