"use strict";

var _react = _interopRequireDefault(require("react"));
var _testUtilities = require("testUtilities");
var _index = _interopRequireDefault(require("./index"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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 = (0, _testUtilities.renderWithProviders)( /*#__PURE__*/_react["default"].createElement(_index["default"], {
      fallback: "invisible"
    }, "visible")),
    queryByText = _renderWithProviders.queryByText;
  expect(queryByText("invisible")).toBeVisible();
  expect(queryByText("visible")).not.toBeInTheDocument();
});
it("calls the observers", function () {
  var _renderWithProviders2 = (0, _testUtilities.renderWithProviders)( /*#__PURE__*/_react["default"].createElement(_index["default"], {
      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);
});