"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _react = _interopRequireWildcard(require("react"));
var _react2 = require("@testing-library/react");
var _useOverlayScrollbar = require("../useOverlayScrollbar");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/providers/useOverlayScrollbar/tests/useOverlayScrollbar.spec.tsx",
  _this = void 0;
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
vi.mock('../useOverlayScrollbar.st.css', () => ({
  st: () => 'mocked-class',
  classes: {
    root: 'mocked-root-class'
  }
}));
describe('useOverlayScrollbar', () => {
  it('sanity check', /*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
    var {
      result
    } = (0, _react2.renderHook)(() => (0, _useOverlayScrollbar.useOverlayScrollbar)());
    var [OverlayScrollbarHostElement, OverlayScrollbarContentElement] = result.current;
    expect(typeof OverlayScrollbarHostElement).toBe('function');
    // forwardRef makes it return object instead of function
    expect(typeof OverlayScrollbarContentElement).toBe('object');
  }));
});
describe('Host and Content Elements', () => {
  it.skip('should render', /*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
    var {
      result
    } = (0, _react2.renderHook)(() => (0, _useOverlayScrollbar.useOverlayScrollbar)());
    var [OverlayScrollbarHostElement, OverlayScrollbarContentElement] = result.current;
    var {
      container
    } = (0, _react2.render)(/*#__PURE__*/_react.default.createElement(OverlayScrollbarHostElement, {
      __self: _this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 33,
        columnNumber: 7
      }
    }, /*#__PURE__*/_react.default.createElement(OverlayScrollbarContentElement, {
      __self: _this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 34,
        columnNumber: 9
      }
    }, "content")));
    expect(container).toMatchSnapshot();
  }));
  it.skip('should work after rerendering child', /*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
    var {
      result
    } = (0, _react2.renderHook)(() => (0, _useOverlayScrollbar.useOverlayScrollbar)());
    var [OverlayScrollbarHostElement, OverlayScrollbarContentElement] = result.current;
    var {
      container,
      rerender
    } = (0, _react2.render)(/*#__PURE__*/_react.default.createElement(OverlayScrollbarHostElement, {
      __self: _this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 48,
        columnNumber: 7
      }
    }, /*#__PURE__*/_react.default.createElement(OverlayScrollbarContentElement, {
      __self: _this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 49,
        columnNumber: 9
      }
    }, "content")));
    rerender(/*#__PURE__*/_react.default.createElement(OverlayScrollbarHostElement, {
      __self: _this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 54,
        columnNumber: 7
      }
    }, /*#__PURE__*/_react.default.createElement(OverlayScrollbarContentElement, {
      __self: _this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 55,
        columnNumber: 9
      }
    }, "new content")));
    expect(container).toMatchSnapshot();
  }));
  it('should keep children mounted during a re-render', () => {
    var onUnmount = vi.fn();
    var Child = () => {
      (0, _react.useEffect)(() => {
        return onUnmount;
      }, []);
      return null;
    };
    var Component = () => {
      var [OverlayScrollbarHostElement, OverlayScrollbarContentElement] = (0, _useOverlayScrollbar.useOverlayScrollbar)();
      return /*#__PURE__*/_react.default.createElement(OverlayScrollbarHostElement, {
        __self: void 0,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 79,
          columnNumber: 9
        }
      }, /*#__PURE__*/_react.default.createElement(OverlayScrollbarContentElement, {
        __self: void 0,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 80,
          columnNumber: 11
        }
      }, /*#__PURE__*/_react.default.createElement(Child, {
        __self: void 0,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 81,
          columnNumber: 13
        }
      })));
    };
    var {
      rerender
    } = (0, _react2.render)(/*#__PURE__*/_react.default.createElement(Component, {
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 87,
        columnNumber: 33
      }
    }));
    rerender(/*#__PURE__*/_react.default.createElement(Component, {
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 88,
        columnNumber: 14
      }
    }));
    expect(onUnmount).not.toHaveBeenCalled();
  });
});
//# sourceMappingURL=useOverlayScrollbar.spec.js.map