import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/esm/ComposerSidebar/test/ComposerSidebar.spec.jsx",
  _this = this;
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
import _regeneratorRuntime from "@babel/runtime/regenerator";
import React from 'react';
import { createRendererWithUniDriver, cleanup } from '../../utils/test-utils/unit';
import ComposerSidebar from '../ComposerSidebar';
import { composerSidebarPrivateDriverFactory } from './ComposerSidebar.private.uni.driver';
import { items, disabledItems } from '../constants';
describe(ComposerSidebar.displayName, function () {
  var render = createRendererWithUniDriver(composerSidebarPrivateDriverFactory);
  afterEach(cleanup);
  it('should render', /*#__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(/*#__PURE__*/React.createElement(ComposerSidebar, {
            selectedId: 2,
            items: items,
            __self: _this,
            __source: {
              fileName: _jsxFileName,
              lineNumber: 19,
              columnNumber: 31
            }
          })), driver = _render.driver;
          _context.t0 = expect;
          _context.next = 4;
          return driver.exists();
        case 4:
          _context.t1 = _context.sent;
          (0, _context.t0)(_context.t1).toBe(true);
          _context.t2 = expect;
          _context.next = 9;
          return driver.getItemLabel(1);
        case 9:
          _context.t3 = _context.sent;
          (0, _context.t2)(_context.t3).toBe('Enhance');
          _context.t4 = expect;
          _context.next = 14;
          return driver.getItemLabel(2);
        case 14:
          _context.t5 = _context.sent;
          (0, _context.t4)(_context.t5).toBe('Adjust');
        case 16:
        case "end":
          return _context.stop();
      }
    }, _callee);
  })));
  it('should call default onClick component callback', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
    var defaultOnClickFn, _render2, driver;
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) switch (_context2.prev = _context2.next) {
        case 0:
          defaultOnClickFn = vi.fn();
          _render2 = render(/*#__PURE__*/React.createElement(ComposerSidebar, {
            onClick: defaultOnClickFn,
            selectedId: 2,
            items: items,
            __self: _this,
            __source: {
              fileName: _jsxFileName,
              lineNumber: 29,
              columnNumber: 7
            }
          })), driver = _render2.driver;
          _context2.next = 4;
          return driver.clickOnItem(1);
        case 4:
          expect(defaultOnClickFn).toHaveBeenCalledWith(expect.any(Object), expect.objectContaining({
            id: 1,
            label: 'Enhance'
          }));
        case 5:
        case "end":
          return _context2.stop();
      }
    }, _callee2);
  })));
  it('should call item onClick callback', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
    var defaultOnClickFn, itemOnClickFn, modifiedItems, _render3, driver;
    return _regeneratorRuntime.wrap(function _callee3$(_context3) {
      while (1) switch (_context3.prev = _context3.next) {
        case 0:
          defaultOnClickFn = vi.fn();
          itemOnClickFn = vi.fn();
          modifiedItems = items.map(function (item) {
            return _objectSpread({}, item);
          });
          modifiedItems[1].onClick = itemOnClickFn;
          _render3 = render(/*#__PURE__*/React.createElement(ComposerSidebar, {
            onClick: defaultOnClickFn,
            selectedId: 2,
            items: modifiedItems,
            __self: _this,
            __source: {
              fileName: _jsxFileName,
              lineNumber: 50,
              columnNumber: 7
            }
          })), driver = _render3.driver;
          _context3.next = 7;
          return driver.clickOnItem(1);
        case 7:
          expect(defaultOnClickFn).not.toHaveBeenCalled();
          expect(itemOnClickFn).toHaveBeenCalledWith(expect.any(Object), expect.objectContaining({
            id: 1,
            label: 'Enhance'
          }));
        case 9:
        case "end":
          return _context3.stop();
      }
    }, _callee3);
  })));
  it('should have a selected item', /*#__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(/*#__PURE__*/React.createElement(ComposerSidebar, {
            selectedId: 2,
            items: items,
            __self: _this,
            __source: {
              fileName: _jsxFileName,
              lineNumber: 67,
              columnNumber: 31
            }
          })), driver = _render4.driver;
          _context4.t0 = expect;
          _context4.next = 4;
          return driver.getSelectedItemId();
        case 4:
          _context4.t1 = _context4.sent;
          (0, _context4.t0)(_context4.t1).toBe('2');
        case 6:
        case "end":
          return _context4.stop();
      }
    }, _callee4);
  })));
  it('should have a disabled item', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
    var _render5, driver;
    return _regeneratorRuntime.wrap(function _callee5$(_context5) {
      while (1) switch (_context5.prev = _context5.next) {
        case 0:
          _render5 = render(/*#__PURE__*/React.createElement(ComposerSidebar, {
            selectedId: 2,
            items: disabledItems,
            __self: _this,
            __source: {
              fileName: _jsxFileName,
              lineNumber: 74,
              columnNumber: 7
            }
          })), driver = _render5.driver;
          _context5.t0 = expect;
          _context5.next = 4;
          return driver.isItemDisabled(0);
        case 4:
          _context5.t1 = _context5.sent;
          (0, _context5.t0)(_context5.t1).toBe(false);
          _context5.t2 = expect;
          _context5.next = 9;
          return driver.isItemDisabled(1);
        case 9:
          _context5.t3 = _context5.sent;
          (0, _context5.t2)(_context5.t3).toBe(true);
        case 11:
        case "end":
          return _context5.stop();
      }
    }, _callee5);
  })));
  it('should have sections assigned to items', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
    var itemsWithSections, _render6, driver;
    return _regeneratorRuntime.wrap(function _callee6$(_context6) {
      while (1) switch (_context6.prev = _context6.next) {
        case 0:
          itemsWithSections = [_objectSpread(_objectSpread({}, items[0]), {}, {
            sectionTitle: 'Important Section'
          }), items[1]];
          _render6 = render(/*#__PURE__*/React.createElement(ComposerSidebar, {
            selectedId: 2,
            items: itemsWithSections,
            __self: _this,
            __source: {
              fileName: _jsxFileName,
              lineNumber: 88,
              columnNumber: 7
            }
          })), driver = _render6.driver;
          _context6.t0 = expect;
          _context6.next = 5;
          return driver.getItemSectionTitle(0);
        case 5:
          _context6.t1 = _context6.sent;
          (0, _context6.t0)(_context6.t1).toBe('Important Section');
          _context6.t2 = expect;
          _context6.next = 10;
          return driver.getItemSectionTitle(1);
        case 10:
          _context6.t3 = _context6.sent;
          (0, _context6.t2)(_context6.t3).toBe(null);
        case 12:
        case "end":
          return _context6.stop();
      }
    }, _callee6);
  })));
  describe('labelPlacement', function () {
    it('should have end value by default [when] not given', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
      var _render7, driver;
      return _regeneratorRuntime.wrap(function _callee7$(_context7) {
        while (1) switch (_context7.prev = _context7.next) {
          case 0:
            _render7 = render(/*#__PURE__*/React.createElement(ComposerSidebar, {
              items: items,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 97,
                columnNumber: 33
              }
            })), driver = _render7.driver;
            _context7.t0 = expect;
            _context7.next = 4;
            return driver.getLabelPlacement();
          case 4:
            _context7.t1 = _context7.sent;
            (0, _context7.t0)(_context7.t1).toBe('end');
          case 6:
          case "end":
            return _context7.stop();
        }
      }, _callee7);
    })));
    it('should have tooltip value [when] given', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
      var labelPlacement, _render8, driver;
      return _regeneratorRuntime.wrap(function _callee8$(_context8) {
        while (1) switch (_context8.prev = _context8.next) {
          case 0:
            labelPlacement = 'tooltip';
            _render8 = render(/*#__PURE__*/React.createElement(ComposerSidebar, {
              items: items,
              labelPlacement: labelPlacement,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 104,
                columnNumber: 9
              }
            })), driver = _render8.driver;
            _context8.t0 = expect;
            _context8.next = 5;
            return driver.getLabelPlacement();
          case 5:
            _context8.t1 = _context8.sent;
            (0, _context8.t0)(_context8.t1).toBe(labelPlacement);
          case 7:
          case "end":
            return _context8.stop();
        }
      }, _callee8);
    })));
  });
});