import { newSpecPage } from '@stencil/core/testing';
import { BsToastActions } from '../bs-toast-actions';
import { faker } from '@faker-js/faker';
import { queryByText } from '@testing-library/dom';
describe('bs-toast-actions', () => {
  describe('Test rendering', () => {
    // Note: for some reason, current version of Stencil testing library does
    // not play well with `HTMLSlotElement.assignedElements`. So, can't test that.
    // Also, had to put '?.' after `assignedElements` for the test to not explode.
    it('renders', async () => {
      const page = await newSpecPage({
        components: [BsToastActions],
        html: `<bs-toast-actions></bs-toast-actions>`
      });
      const component = page.root.querySelector('.bs-toast-actions');
      expect(queryByText(component, 'Dismiss'));
    });
    it('renders actions when given', async () => {
      const action1 = faker.random.word();
      const action2 = faker.random.word();
      const action3 = faker.random.word();
      const page = await newSpecPage({
        components: [BsToastActions],
        html: `
          <bs-toast-actions>
            <bs-button>${action1}</bs-button>
            <bs-button>${action2}</bs-button>
            <bs-button>${action3}</bs-button>
          </bs-toast-actions>`
      });
      const component = page.root.querySelector('.bs-toast-actions');
      expect(queryByText(component, action1));
      expect(queryByText(component, action2));
      expect(queryByText(component, action3));
    });
  });
  describe('Test event handling', () => {
    it('handles default dismiss event', async () => {
      const page = await newSpecPage({
        components: [BsToastActions],
        html: `<bs-toast-actions></bs-toast-actions>`
      });
      const mockCallback = jest.fn();
      const root = page.root;
      root.addEventListener('defaultDismiss', mockCallback);
      root.querySelector('bs-button').click();
      expect(mockCallback).toHaveBeenCalled();
    });
  });
});
//# sourceMappingURL=bs-toast-actions.spec.js.map
