import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import _extends from "@babel/runtime/helpers/extends";
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/esm/SortableListBase/test/SortableListBase.spec.jsx",
  _this = this;
import _regeneratorRuntime from "@babel/runtime/regenerator";
import React from 'react';
import { createRendererWithUniDriver, cleanup } from '../../utils/test-utils/react';
import SortableListBase from '../SortableListBase';
import { sortableListBaseUniDriverFactory } from '../SortableListBase.uni.driver';
describe('SortableListBase', function () {
  describe('[async]', function () {
    runTests(createRendererWithUniDriver(sortableListBaseUniDriverFactory));
  });
});
var renderSortableListBase = function renderSortableListBase(props) {
  var dataHook = 'sortable-list';
  var items = [{
    id: '0',
    text: 'item 0'
  }, {
    id: '1',
    text: 'item 1'
  }, {
    id: '2',
    text: 'item 2'
  }];
  var renderItem = function renderItem(_ref) {
    var item = _ref.item;
    return /*#__PURE__*/React.createElement("div", {
      "data-hook": "item-".concat(item.id),
      __self: _this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 25,
        columnNumber: 5
      }
    }, item.text);
  };
  return /*#__PURE__*/React.createElement(SortableListBase, _extends({
    contentClassName: "cl",
    dataHook: dataHook,
    containerId: "sortable-list",
    items: items,
    renderItem: renderItem,
    onDrop: function onDrop() {}
  }, props, {
    __self: _this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 29,
      columnNumber: 5
    }
  }));
};
function runTests(render) {
  afterEach(function () {
    return cleanup();
  });
  it('should reorder', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
    var _render, driver;
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) switch (_context.prev = _context.next) {
        case 0:
          _render = render(renderSortableListBase()), driver = _render.driver;
          _context.next = 3;
          return driver.reorder({
            dataHookFrom: 'item-0',
            dataHookTo: 'item-1'
          });
        case 3:
          _context.t0 = expect;
          _context.next = 6;
          return driver.getItemPosition({
            dataHook: 'item-0'
          });
        case 6:
          _context.t1 = _context.sent;
          (0, _context.t0)(_context.t1).toBe(1);
        case 8:
        case "end":
          return _context.stop();
      }
    }, _callee);
  })));
  it('should reorder with portal', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
    var _render2, driver;
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) switch (_context2.prev = _context2.next) {
        case 0:
          _render2 = render(renderSortableListBase({
            usePortal: true
          })), driver = _render2.driver;
          _context2.next = 3;
          return driver.reorder({
            dataHookFrom: 'item-0',
            dataHookTo: 'item-1'
          });
        case 3:
          _context2.t0 = expect;
          _context2.next = 6;
          return driver.getItemPosition({
            dataHook: 'item-0'
          });
        case 6:
          _context2.t1 = _context2.sent;
          (0, _context2.t0)(_context2.t1).toBe(1);
        case 8:
        case "end":
          return _context2.stop();
      }
    }, _callee2);
  })));
  it('should insert at the end of the list', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
    var _render3, driver;
    return _regeneratorRuntime.wrap(function _callee3$(_context3) {
      while (1) switch (_context3.prev = _context3.next) {
        case 0:
          _render3 = render(renderSortableListBase({
            insertPosition: 'end'
          })), driver = _render3.driver;
          _context3.next = 3;
          return driver.reorder({
            dataHookFrom: 'item-0',
            dataHookTo: 'item-1'
          });
        case 3:
          _context3.t0 = expect;
          _context3.next = 6;
          return driver.getItemPosition({
            dataHook: 'item-0'
          });
        case 6:
          _context3.t1 = _context3.sent;
          (0, _context3.t0)(_context3.t1).toBe(2);
        case 8:
        case "end":
          return _context3.stop();
      }
    }, _callee3);
  })));
  it('should insert at the start of the list', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
    var _render4, driver;
    return _regeneratorRuntime.wrap(function _callee4$(_context4) {
      while (1) switch (_context4.prev = _context4.next) {
        case 0:
          _render4 = render(renderSortableListBase({
            insertPosition: 'start'
          })), driver = _render4.driver;
          _context4.next = 3;
          return driver.reorder({
            dataHookFrom: 'item-0',
            dataHookTo: 'item-1'
          });
        case 3:
          _context4.t0 = expect;
          _context4.next = 6;
          return driver.getItemPosition({
            dataHook: 'item-0'
          });
        case 6:
          _context4.t1 = _context4.sent;
          (0, _context4.t0)(_context4.t1).toBe(0);
        case 8:
        case "end":
          return _context4.stop();
      }
    }, _callee4);
  })));
}