import { newSpecPage } from '@stencil/core/testing';
import { BsBanner } from '../bs-banner';
import { faker } from '@faker-js/faker';
import { queryByText } from '@testing-library/dom';
describe('bs-banner', () => {
  const message = faker.random.words(5);
  let page = null;
  let component = null;
  beforeEach(async () => {
    page = await newSpecPage({
      components: [BsBanner],
      html: `<bs-banner>${message}</bs-banner>`,
    });
    component = page.root;
  });
  it('renders', async () => {
    expect(component).not.toHaveAttribute('data-dismissed');
    expect(queryByText(component, message));
  });
  it('should show \'data-dismissed\' attribute when dismissed', async () => {
    const closeButton = component.querySelector('.bs-banner-content button');
    closeButton.click();
    await page.waitForChanges();
    expect(component).toHaveAttribute('data-dismissed');
  });
  it('should emit \'dismiss\' event when dismissed', done => {
    // Async callback that does the actual testing
    const callback = () => {
      expect(true).toBeTruthy();
      // `done` test parameter called to signal Jest that the test is actually done
      // Note: if this is not called in a reasonable amount of time (probably configurable in Jest),
      //       the test will be marked as a failure. This essentially means the async call took too long
      done();
    };
    component.addEventListener('dismiss', callback);
    const closeButton = component.querySelector('.bs-banner-content button');
    // Trigger the async test callback
    closeButton.click();
  });
});
//# sourceMappingURL=bs-banner.spec.js.map
