import { renderHook } from './../_node_modules/@testing-library/react/dist/@testing-library/react.esm.js';
import { useEventListener } from "./useEventListener.js";
describe("useEventListener", () => {
  it("should add event listener to the specified element", () => {
    const addEventListenerMock = jest.fn();
    const removeEventListenerMock = jest.fn();
    const elementMock = {
      addEventListener: addEventListenerMock,
      removeEventListener: removeEventListenerMock
    };
    const eventHandler = jest.fn();
    const eventType = "click";
    renderHook(() => useEventListener(eventType, eventHandler, elementMock));
    expect(addEventListenerMock).toHaveBeenCalledWith(eventType, eventHandler, {
      passive: true
    });
  });
  it("should remove event listener when component unmounts", () => {
    const addEventListenerMock = jest.fn();
    const removeEventListenerMock = jest.fn();
    const elementMock = {
      addEventListener: addEventListenerMock,
      removeEventListener: removeEventListenerMock
    };
    const eventHandler = jest.fn();
    const eventType = "click";
    const { unmount } = renderHook(() => useEventListener(eventType, eventHandler, elementMock));
    unmount();
    expect(removeEventListenerMock).toHaveBeenCalledWith(eventType, eventHandler, {});
  });
  it("should not add event listener if the element is undefined", () => {
    const addEventListenerMock = jest.fn();
    const elementMock = void 0;
    const eventHandler = jest.fn();
    const eventType = "click";
    renderHook(() => useEventListener(eventType, eventHandler, elementMock));
    expect(addEventListenerMock).not.toHaveBeenCalled();
  });
});
//# sourceMappingURL=useEventListener.spec.js.map
