import { newSpecPage } from '@stencil/core/testing';
import { BsInputField } from '../bs-input-field';
import { faker } from '@faker-js/faker';
const hint = faker.random.words();
const id = faker.datatype.uuid();
const label = faker.random.words();
describe('bs-input-field', () => {
  it('renders input only by default', async () => {
    const page = await newSpecPage({
      components: [BsInputField],
      html: `<bs-input-field></bs-input-field>`,
    });
    expect(page.root.querySelector('bs-input')).toBeTruthy();
    expect(page.root.querySelector('bs-label')).toBeNull();
    expect(page.root.querySelector('bs-hint')).toBeNull();
  });
  it('handles label prop and id by passing values to bs-field-layout', async () => {
    const page = await newSpecPage({
      components: [BsInputField],
      html: `<bs-input-field id="${id}" label="${label}"></bs-input-field>`,
    });
    const component = page.root;
    const bsField = component.querySelector('bs-field-layout');
    expect(bsField.getAttribute('label')).toBe(label);
    expect(bsField.getAttribute('label-for')).toBe(id);
  });
  it('handles hints prop by passing value to bs-field-layout', async () => {
    const page = await newSpecPage({
      components: [BsInputField],
      html: `<bs-input-field hints="${hint}"></bs-input-field>`,
    });
    const component = page.root;
    const bsField = component.querySelector('bs-field-layout');
    expect(bsField.getAttribute('hints')).toBe(hint);
  });
  it('handles hints prop by generating and passing uuid to bs-input, bs-field-layout', async () => {
    const page = await newSpecPage({
      components: [BsInputField],
      html: `<bs-input-field hints="${hint}"></bs-input-field>`,
    });
    const component = page.root;
    const bsField = component.querySelector('bs-field-layout');
    const bsFieldHintId = bsField.getAttribute('hintid');
    const bsInput = component.querySelector('bs-input');
    const bsInputHintId = bsInput.getAttribute('hintid');
    expect(bsFieldHintId).toBeTruthy();
    expect(bsInputHintId).toBe(bsFieldHintId);
  });
});
//# sourceMappingURL=bs-input-field.spec.js.map
