import { faker } from '@faker-js/faker';
import { newSpecPage } from '@stencil/core/testing';
import { BsSwitch } from '../bs-switch';
const id = faker.random.word();
const labelText = faker.random.word();
const name = faker.random.word();
const offText = faker.random.words(3);
const onText = faker.random.words(3);
describe('bs-switch', () => {
  it('passes attributes correctly to label and input', async () => {
    const page = await newSpecPage({
      components: [BsSwitch],
      html: `<bs-switch input-id="${id}" name="${name}" label="${labelText}"></bs-switch>`,
    });
    const bsLabel = page.root.querySelector('bs-label');
    const input = page.root.querySelector('input');
    expect(bsLabel.getAttribute('for')).toBe(id);
    expect(input.getAttribute('id')).toBe(id);
    expect(input.getAttribute('name')).toBe(name);
  });
  it('handles the checked prop', async () => {
    const page = await newSpecPage({
      components: [BsSwitch],
      html: `<bs-switch checked="false"></bs-switch>`,
    });
    const input = page.root.querySelector('input');
    expect(input).not.toHaveAttribute('checked');
    page.root.checked = true;
    await page.waitForChanges();
    expect(input).toHaveAttribute('checked');
  });
  it('handles the innerOnLabel prop', async () => {
    const page = await newSpecPage({
      components: [BsSwitch],
      html: `<bs-switch></bs-switch>`,
    });
    const toggleWrap = page.root.querySelector('.bs-switch');
    const toggle = toggleWrap.querySelector('span');
    expect(toggle).not.toHaveAttribute('data-inner-on-label');
    page.root.innerOnLabel = onText;
    await page.waitForChanges();
    expect(toggle.getAttribute('data-inner-on-label')).toBe(onText);
  });
  it('handles the innerOffLabel prop', async () => {
    const page = await newSpecPage({
      components: [BsSwitch],
      html: `<bs-switch></bs-switch>`,
    });
    const toggleWrap = page.root.querySelector('.bs-switch');
    const toggle = toggleWrap.querySelector('span');
    expect(toggle).not.toHaveAttribute('data-inner-off-label');
    page.root.innerOffLabel = offText;
    await page.waitForChanges();
    expect(toggle.getAttribute('data-inner-off-label')).toBe(offText);
  });
  it('handles the disabled prop', async () => {
    const page = await newSpecPage({
      components: [BsSwitch],
      html: `<bs-switch label="${labelText}"></bs-switch>`,
    });
    const bsLabel = page.root.querySelector('bs-label');
    const toggleWrap = page.root.querySelector('.bs-switch');
    const input = page.root.querySelector('input');
    expect(bsLabel).not.toHaveAttribute('disabled');
    expect(toggleWrap).not.toHaveAttribute('data-disabled');
    expect(input).not.toHaveAttribute('disabled');
    page.root.disabled = true;
    await page.waitForChanges();
    expect(bsLabel).toHaveAttribute('disabled');
    expect(toggleWrap).toHaveAttribute('data-disabled');
    expect(input).toHaveAttribute('disabled');
  });
  it('handles the size prop', async () => {
    const page = await newSpecPage({
      components: [BsSwitch],
      html: `<bs-switch></bs-switch>`,
    });
    const toggleWrap = page.root.querySelector('.bs-switch');
    expect(page.root).not.toHaveAttribute('data-size');
    expect(toggleWrap).not.toHaveAttribute('data-size');
    page.root.size = 'sm';
    await page.waitForChanges();
    expect(page.root.getAttribute('data-size')).toBe('sm');
    expect(toggleWrap.getAttribute('data-size')).toBe('sm');
  });
});
//# sourceMappingURL=bs-switch.spec.js.map
