import { faker } from '@faker-js/faker';
import { newSpecPage } from '@stencil/core/testing';
import { BsProfileImg } from '../bs-profile-img';
describe('bs-profile-img', () => {
  const name = faker.name.fullName();
  const initials = faker.random.alpha(2);
  const imgSrc = faker.image.imageUrl();
  it('renders an image when src is present', async () => {
    const page = await newSpecPage({
      components: [BsProfileImg],
      html: `<bs-profile-img profile-name="${name}" src="${imgSrc}"></bs-profile-img>`,
    });
    const component = page.root;
    const imgElement = component.querySelector('img');
    const container = page.root.getElementsByClassName('bs-profile-img')[0];
    expect(imgElement.getAttribute('src')).toBe(imgSrc);
    expect(imgElement.getAttribute('alt')).toBe(`${name} Profile Photo.`);
    expect(container).not.toHaveAttribute('data-no-img');
  });
  it('renders initials and no image when src is NOT present', async () => {
    const page = await newSpecPage({
      components: [BsProfileImg],
      html: `<bs-profile-img profile-name="${name}" initials="${initials}"></bs-profile-img>`,
    });
    const component = page.root;
    const container = page.root.getElementsByClassName('bs-profile-img')[0];
    // Initials are displayed when no image is present, but that is done through CSS so we are just checking for the initial prop here.
    expect(container.getAttribute('data-initials')).toBe(initials);
    expect(container).toHaveAttribute('data-no-img');
    const imgElement = component.querySelector('img');
    expect(imgElement).toBeFalsy();
  });
  it('the size of the image is adjustable', async () => {
    const size = faker.helpers.arrayElement(['xs', 'sm', 'md', 'lg', 'xl']);
    const page = await newSpecPage({
      components: [BsProfileImg],
      html: `<bs-profile-img profile-name="${name}" src="${imgSrc}" size="${size}"></bs-profile-img>`,
    });
    const container = page.root.getElementsByClassName('bs-profile-img')[0];
    expect(container.getAttribute('data-img-size')).toBe(size);
    expect(container).not.toHaveAttribute('data-no-img');
  });
});
//# sourceMappingURL=bs-profile-img.spec.js.map
