import { newSpecPage } from '@stencil/core/testing';
import { BsDropdown } from '../bs-dropdown';
import { faker } from '@faker-js/faker';
describe('bs-dropdown', () => {
  describe('Test rendering', () => {
    it('renders when justify center given', async () => {
      const page = await newSpecPage({
        components: [BsDropdown],
        html: `<bs-dropdown justify="center"></bs-dropdown>`,
      });
      expect(page.root.getAttribute('data-justify')).toBe('center');
    });
    it('renders when justify undefined', async () => {
      const page = await newSpecPage({
        components: [BsDropdown],
        html: `<bs-dropdown></bs-dropdown>`,
      });
      expect(page.root.getAttribute('data-justify')).toBeNull();
    });
  });
  describe('Test component class logic', () => {
    let comp;
    beforeEach(() => {
      comp = new BsDropdown();
    });
    describe('componentDidRender()', () => {
      let dropdownId;
      let label;
      let optionsEl;
      beforeEach(() => {
        dropdownId = faker.random.alphaNumeric(10);
        label = faker.random.words(2);
        optionsEl = document.createElement('bs-dropdown-options');
        jest.spyOn(comp, 'optionsEl', 'get').mockReturnValue(optionsEl);
        comp.dropdownId = dropdownId;
        comp.label = label;
        comp.variant = 'fit';
        comp.position = 'top';
      });
      it('should send down props when shown is true', () => {
        comp.shown = true;
        comp.componentDidRender();
        expect(optionsEl.getAttribute('dropdown-id')).toBe(dropdownId);
        expect(optionsEl.getAttribute('dropdownid')).toBe(dropdownId);
        expect(optionsEl.getAttribute('shown')).toBe('true');
        expect(optionsEl.getAttribute('label')).toBe(label);
        expect(optionsEl.getAttribute('variant')).toBe('fit');
        expect(optionsEl.getAttribute('position')).toBe('top');
      });
      it('should send down props when shown is false', () => {
        comp.shown = false;
        comp.componentDidRender();
        expect(optionsEl.getAttribute('dropdown-id')).toBe(dropdownId);
        expect(optionsEl.getAttribute('dropdownid')).toBe(dropdownId);
        expect(optionsEl.getAttribute('shown')).toBe('false');
        expect(optionsEl.getAttribute('label')).toBe(label);
        expect(optionsEl.getAttribute('variant')).toBe('fit');
        expect(optionsEl.getAttribute('position')).toBe('top');
      });
    });
  });
});
//# sourceMappingURL=bs-dropdown.spec.js.map
