import React from "react";
import { renderWithProviders } from "testUtilities";
import Intersection from "./index";
var observe;
var unobserve;
var disconnect;
beforeEach(function () {
  observe = jest.fn();
  unobserve = jest.fn();
  disconnect = jest.fn();
  global.IntersectionObserver = jest.fn(function () {
    return {
      observe: observe,
      unobserve: unobserve,
      disconnect: disconnect
    };
  });
});
it("renders", function () {
  var _renderWithProviders = renderWithProviders( /*#__PURE__*/React.createElement(Intersection, {
      fallback: "invisible"
    }, "visible")),
    queryByText = _renderWithProviders.queryByText;
  expect(queryByText("invisible")).toBeVisible();
  expect(queryByText("visible")).not.toBeInTheDocument();
});
it("calls the observers", function () {
  var _renderWithProviders2 = renderWithProviders( /*#__PURE__*/React.createElement(Intersection, {
      fallback: "invisible"
    }, "visible")),
    unmount = _renderWithProviders2.unmount,
    container = _renderWithProviders2.container;
  expect(observe).toBeCalledWith(container.firstChild);
  expect(observe).toBeCalledTimes(1);
  expect(unobserve).toBeCalledTimes(0);
  expect(disconnect).toBeCalledTimes(0);
  unmount();
  expect(observe).toBeCalledTimes(1);
  expect(unobserve).toBeCalledTimes(1);
  expect(disconnect).toBeCalledTimes(1);
});