import _extends from "@babel/runtime/helpers/extends";
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["expected"];
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/esm/common/ScrollableContainer/test/ScrollableContainer.visual.jsx",
  _this = this;
import React, { useEffect, useState } from 'react';
import { storiesOf } from '@storybook/react';
import ScrollableContainer from '../ScrollableContainer';
import { scrollableContainerPrivateUniDriverFactory } from './ScrollableContainer.private.uni.driver';
import { testkitFactoryCreator } from '@wix/wix-ui-test-utils/vanilla';
import { AreaY } from '../index';
var commonProps = {
  style: {
    height: '300px',
    width: '200px',
    border: '1px solid black'
  },
  children: new Array(50).fill('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do ').join()
};
var scrollableContainerTestkitFactory = testkitFactoryCreator(scrollableContainerPrivateUniDriverFactory);
var dataHook = 'scrollable-container';
var createDriver = function createDriver() {
  return scrollableContainerTestkitFactory({
    wrapper: document.body,
    dataHook: dataHook
  });
};
var tests = [{
  describe: 'scroll-y area',
  its: [],
  skippedIts: [{
    it: 'no scroll',
    props: {
      children: 'short text'
    },
    expected: AreaY.NONE
  }, {
    it: 'scrolled to top',
    props: {},
    expected: AreaY.TOP
  }, {
    it: 'scrolled to middle',
    props: {},
    expected: AreaY.MIDDLE,
    componentDidMount: function componentDidMount() {
      createDriver()._scrollContentTo({
        y: 375
      });
    }
  }, {
    it: 'scrolled to bottom',
    props: {},
    expected: AreaY.BOTTOM,
    componentDidMount: function componentDidMount() {
      createDriver()._scrollContentTo({
        y: 99999
      });
    }
  }]
}, {
  describe: 'scroll-y information',
  its: [{
    it: 'scrolled to 500',
    props: {},
    expected: 500,
    componentDidMount: function componentDidMount() {
      createDriver()._scrollContentTo({
        y: 500
      });
    }
  }]
}];
var ScrollableContainerWrapper = function ScrollableContainerWrapper(_ref) {
  var expected = _ref.expected,
    props = _objectWithoutProperties(_ref, _excluded);
  var _useState = useState(''),
    _useState2 = _slicedToArray(_useState, 2),
    scrollArea = _useState2[0],
    setScrollArea = _useState2[1];
  var _useState3 = useState(0),
    _useState4 = _slicedToArray(_useState3, 2),
    scrollTop = _useState4[0],
    setScrollTop = _useState4[1];
  var handleScrollAreaChanged = function handleScrollAreaChanged(_ref2) {
    var area = _ref2.area;
    return setScrollArea(area.y);
  };
  var handleScrollChanged = function handleScrollChanged(_ref3) {
    var target = _ref3.target;
    return setScrollTop(target.scrollTop);
  };
  return /*#__PURE__*/React.createElement("div", {
    __self: _this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 86,
      columnNumber: 5
    }
  }, /*#__PURE__*/React.createElement(ScrollableContainer, _extends({}, props, {
    onScrollAreaChanged: handleScrollAreaChanged,
    onScrollChanged: handleScrollChanged,
    __self: _this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 87,
      columnNumber: 7
    }
  })), /*#__PURE__*/React.createElement("br", {
    __self: _this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 92,
      columnNumber: 7
    }
  }), /*#__PURE__*/React.createElement("div", {
    __self: _this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 93,
      columnNumber: 7
    }
  }, "Scroll-Y:", /*#__PURE__*/React.createElement("ul", {
    __self: _this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 95,
      columnNumber: 9
    }
  }, /*#__PURE__*/React.createElement("li", {
    "data-test-ready": scrollArea === expected,
    __self: _this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 96,
      columnNumber: 11
    }
  }, "Area: ".concat(scrollArea)), /*#__PURE__*/React.createElement("li", {
    "data-test-ready": scrollTop === expected,
    __self: _this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 99,
      columnNumber: 11
    }
  }, "scrollTop: ".concat(scrollTop)))));
};
tests.forEach(function (_ref4) {
  var describe = _ref4.describe,
    its = _ref4.its;
  its.forEach(function (_ref5) {
    var it = _ref5.it,
      props = _ref5.props,
      componentDidMount = _ref5.componentDidMount,
      expected = _ref5.expected;
    storiesOf("ScrollableContainer".concat(describe ? '/' + describe : ''), module).add(it, function () {
      useEffect(function () {
        componentDidMount && componentDidMount();
      }, []);
      return /*#__PURE__*/React.createElement(ScrollableContainerWrapper, _extends({
        componentDidMount: componentDidMount,
        expected: expected,
        dataHook: dataHook
      }, commonProps, props, {
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 120,
          columnNumber: 11
        }
      }));
    }, {
      eyes: {
        waitBeforeScreenshot: "[data-test-ready=\"true\"]"
      }
    });
  });
});