import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/esm/Breadcrumbs/test/Breadcrumbs.spec.jsx";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import React from 'react';
import { createRendererWithUniDriver, cleanup } from '../../utils/test-utils/react';
import { breadcrumbsUniDriverFactory } from '../Breadcrumbs.uni.driver';
import Breadcrumbs from '../Breadcrumbs';
var items = [{
  id: 0,
  value: 'Option 1'
}, {
  id: 1,
  value: 'Option 2'
}];
var onClick;
describe('Breadcrumbs', function () {
  describe('[async]', function () {
    runTests(createRendererWithUniDriver(breadcrumbsUniDriverFactory));
  });
  function runTests(render) {
    var _this = this;
    beforeEach(function () {
      onClick = vi.fn();
    });
    afterEach(function () {
      return cleanup();
    });
    it('should have correct text on each breadcrumb', /*#__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(Breadcrumbs, {
              onClick: onClick,
              items: items,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 30,
                columnNumber: 33
              }
            })), driver = _render.driver;
            _context.t0 = expect;
            _context.next = 4;
            return driver.breadcrumbsLength();
          case 4:
            _context.t1 = _context.sent;
            (0, _context.t0)(_context.t1).toBe(items.length);
            _context.t2 = expect;
            _context.next = 9;
            return driver.breadcrumbContentAt(0);
          case 9:
            _context.t3 = _context.sent;
            (0, _context.t2)(_context.t3).toBe(items[0].value);
            _context.t4 = expect;
            _context.next = 14;
            return driver.breadcrumbContentAt(1);
          case 14:
            _context.t5 = _context.sent;
            (0, _context.t4)(_context.t5).toBe(items[1].value);
          case 16:
          case "end":
            return _context.stop();
        }
      }, _callee);
    })));
    it('should call onClick callback on click with correct item', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
      var _render2, driver, itemIndex;
      return _regeneratorRuntime.wrap(function _callee2$(_context2) {
        while (1) switch (_context2.prev = _context2.next) {
          case 0:
            _render2 = render(/*#__PURE__*/React.createElement(Breadcrumbs, {
              onClick: onClick,
              items: items,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 37,
                columnNumber: 33
              }
            })), driver = _render2.driver;
            itemIndex = 1;
            _context2.next = 4;
            return driver.clickBreadcrumbAt(itemIndex);
          case 4:
            expect(onClick).toHaveBeenCalledWith({
              id: items[itemIndex].id,
              value: 'Option 2'
            }, expect.objectContaining({
              type: 'click'
            }));
          case 5:
          case "end":
            return _context2.stop();
        }
      }, _callee2);
    })));
    it('should get large size from props', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
      var size, _render3, driver;
      return _regeneratorRuntime.wrap(function _callee3$(_context3) {
        while (1) switch (_context3.prev = _context3.next) {
          case 0:
            size = 'large';
            _render3 = render(/*#__PURE__*/React.createElement(Breadcrumbs, {
              onClick: onClick,
              items: items,
              size: size,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 49,
                columnNumber: 33
              }
            })), driver = _render3.driver;
            _context3.t0 = expect;
            _context3.next = 5;
            return driver.isLarge();
          case 5:
            _context3.t1 = _context3.sent;
            (0, _context3.t0)(_context3.t1).toBe(true);
          case 7:
          case "end":
            return _context3.stop();
        }
      }, _callee3);
    })));
    it('should get small size from props', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
      var size, _render4, driver;
      return _regeneratorRuntime.wrap(function _callee4$(_context4) {
        while (1) switch (_context4.prev = _context4.next) {
          case 0:
            size = 'small';
            _render4 = render(/*#__PURE__*/React.createElement(Breadcrumbs, {
              onClick: onClick,
              items: items,
              size: size,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 55,
                columnNumber: 33
              }
            })), driver = _render4.driver;
            _context4.t0 = expect;
            _context4.next = 5;
            return driver.isSmall();
          case 5:
            _context4.t1 = _context4.sent;
            (0, _context4.t0)(_context4.t1).toBe(true);
          case 7:
          case "end":
            return _context4.stop();
        }
      }, _callee4);
    })));
    it('should use medium size as default', /*#__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(Breadcrumbs, {
              onClick: onClick,
              items: items,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 60,
                columnNumber: 33
              }
            })), driver = _render5.driver;
            _context5.t0 = expect;
            _context5.next = 4;
            return driver.isMedium();
          case 4:
            _context5.t1 = _context5.sent;
            (0, _context5.t0)(_context5.t1).toBe(true);
          case 6:
          case "end":
            return _context5.stop();
        }
      }, _callee5);
    })));
    it('should get theme from props', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
      var theme, _render6, driver;
      return _regeneratorRuntime.wrap(function _callee6$(_context6) {
        while (1) switch (_context6.prev = _context6.next) {
          case 0:
            theme = 'onWhiteBackground';
            _render6 = render(/*#__PURE__*/React.createElement(Breadcrumbs, {
              onClick: onClick,
              items: items,
              theme: theme,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 66,
                columnNumber: 33
              }
            })), driver = _render6.driver;
            _context6.t0 = expect;
            _context6.next = 5;
            return driver.isOnWhiteBackground();
          case 5:
            _context6.t1 = _context6.sent;
            (0, _context6.t0)(_context6.t1).toBe(true);
          case 7:
          case "end":
            return _context6.stop();
        }
      }, _callee6);
    })));
    it('should use default theme gray background', /*#__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(Breadcrumbs, {
              onClick: onClick,
              items: items,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 71,
                columnNumber: 33
              }
            })), driver = _render7.driver;
            _context7.t0 = expect;
            _context7.next = 4;
            return driver.isOnGrayBackground();
          case 4:
            _context7.t1 = _context7.sent;
            (0, _context7.t0)(_context7.t1).toBe(true);
          case 6:
          case "end":
            return _context7.stop();
        }
      }, _callee7);
    })));
    it('should get skin from props', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
      var skin, _render8, driver;
      return _regeneratorRuntime.wrap(function _callee8$(_context8) {
        while (1) switch (_context8.prev = _context8.next) {
          case 0:
            skin = 'onWhiteBackground';
            _render8 = render(/*#__PURE__*/React.createElement(Breadcrumbs, {
              onClick: onClick,
              items: items,
              skin: skin,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 77,
                columnNumber: 33
              }
            })), driver = _render8.driver;
            _context8.t0 = expect;
            _context8.next = 5;
            return driver.isOnWhiteBackground();
          case 5:
            _context8.t1 = _context8.sent;
            (0, _context8.t0)(_context8.t1).toBe(true);
          case 7:
          case "end":
            return _context8.stop();
        }
      }, _callee8);
    })));
    it('should get active id from props and have correct class', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
      var itemIndex, _render9, driver;
      return _regeneratorRuntime.wrap(function _callee9$(_context9) {
        while (1) switch (_context9.prev = _context9.next) {
          case 0:
            itemIndex = 1;
            _render9 = render(/*#__PURE__*/React.createElement(Breadcrumbs, {
              onClick: onClick,
              items: items,
              activeId: items[itemIndex].id,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 84,
                columnNumber: 9
              }
            })), driver = _render9.driver;
            _context9.t0 = expect;
            _context9.next = 5;
            return driver.getActiveItemId();
          case 5:
            _context9.t1 = _context9.sent;
            (0, _context9.t0)(_context9.t1).toBe(itemIndex);
          case 7:
          case "end":
            return _context9.stop();
        }
      }, _callee9);
    })));
    it('should return null if not exists active id', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0() {
      var _render0, driver;
      return _regeneratorRuntime.wrap(function _callee0$(_context0) {
        while (1) switch (_context0.prev = _context0.next) {
          case 0:
            _render0 = render(/*#__PURE__*/React.createElement(Breadcrumbs, {
              onClick: onClick,
              items: items,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 90,
                columnNumber: 33
              }
            })), driver = _render0.driver;
            _context0.t0 = expect;
            _context0.next = 4;
            return driver.getActiveItemId();
          case 4:
            _context0.t1 = _context0.sent;
            (0, _context0.t0)(_context0.t1).toBe(null);
          case 6:
          case "end":
            return _context0.stop();
        }
      }, _callee0);
    })));
    describe('item with link attribute', function () {
      var linkItems = [{
        id: 0,
        value: 'Option 1',
        link: '//www.wix.com'
      }, {
        id: 1,
        value: 'Option 2',
        link: '//www.facebook.com'
      }];
      it('should not have links if link attribute is not given', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee1() {
        var _render1, driver;
        return _regeneratorRuntime.wrap(function _callee1$(_context1) {
          while (1) switch (_context1.prev = _context1.next) {
            case 0:
              _render1 = render(/*#__PURE__*/React.createElement(Breadcrumbs, {
                items: items,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 101,
                  columnNumber: 35
                }
              })), driver = _render1.driver;
              _context1.t0 = expect;
              _context1.next = 4;
              return driver.isActiveLinkAt(0);
            case 4:
              _context1.t1 = _context1.sent;
              (0, _context1.t0)(_context1.t1).toBe(false);
              _context1.t2 = expect;
              _context1.next = 9;
              return driver.isActiveLinkAt(1);
            case 9:
              _context1.t3 = _context1.sent;
              (0, _context1.t2)(_context1.t3).toBe(false);
            case 11:
            case "end":
              return _context1.stop();
          }
        }, _callee1);
      })));
      it('should be a link if no activeId is given', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
        var _render10, driver;
        return _regeneratorRuntime.wrap(function _callee10$(_context10) {
          while (1) switch (_context10.prev = _context10.next) {
            case 0:
              _render10 = render(/*#__PURE__*/React.createElement(Breadcrumbs, {
                items: linkItems,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 107,
                  columnNumber: 35
                }
              })), driver = _render10.driver;
              _context10.t0 = expect;
              _context10.next = 4;
              return driver.isActiveLinkAt(0);
            case 4:
              _context10.t1 = _context10.sent;
              (0, _context10.t0)(_context10.t1).toBe(true);
              _context10.t2 = expect;
              _context10.next = 9;
              return driver.isActiveLinkAt(1);
            case 9:
              _context10.t3 = _context10.sent;
              (0, _context10.t2)(_context10.t3).toBe(true);
            case 11:
            case "end":
              return _context10.stop();
          }
        }, _callee10);
      })));
      it('should not be a link if it is the item with activeId', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
        var _render11, driver;
        return _regeneratorRuntime.wrap(function _callee11$(_context11) {
          while (1) switch (_context11.prev = _context11.next) {
            case 0:
              _render11 = render(/*#__PURE__*/React.createElement(Breadcrumbs, {
                items: linkItems,
                activeId: 0,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 114,
                  columnNumber: 11
                }
              })), driver = _render11.driver;
              _context11.t0 = expect;
              _context11.next = 4;
              return driver.isActiveLinkAt(0);
            case 4:
              _context11.t1 = _context11.sent;
              (0, _context11.t0)(_context11.t1).toBe(false);
              _context11.t2 = expect;
              _context11.next = 9;
              return driver.isActiveLinkAt(1);
            case 9:
              _context11.t3 = _context11.sent;
              (0, _context11.t2)(_context11.t3).toBe(true);
            case 11:
            case "end":
              return _context11.stop();
          }
        }, _callee11);
      })));
    });
    describe('customElement attribute', function () {
      var customItems = [{
        id: 0,
        value: 'Option 1',
        customElement: /*#__PURE__*/React.createElement("a", {
          href: "//www.wix.com",
          __self: _this,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 126,
            columnNumber: 26
          }
        }, "Option 1")
      }, {
        id: 1,
        value: 'Option 2',
        customElement: /*#__PURE__*/React.createElement("a", {
          href: "//www.facebook.com",
          __self: _this,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 131,
            columnNumber: 26
          }
        }, "Option 2")
      }];
      var customItemsWithLinks = [{
        id: 0,
        value: 'value',
        customElement: /*#__PURE__*/React.createElement("a", {
          href: "//www.wix.com",
          __self: _this,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 139,
            columnNumber: 26
          }
        }, "Custom value"),
        link: 'www.bla.com'
      }];
      it('should render the customElement when given', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
        var _render12, driver;
        return _regeneratorRuntime.wrap(function _callee12$(_context12) {
          while (1) switch (_context12.prev = _context12.next) {
            case 0:
              _render12 = render(/*#__PURE__*/React.createElement(Breadcrumbs, {
                items: customItems,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 145,
                  columnNumber: 35
                }
              })), driver = _render12.driver;
              _context12.t0 = expect;
              _context12.next = 4;
              return driver.breadcrumbsLength();
            case 4:
              _context12.t1 = _context12.sent;
              (0, _context12.t0)(_context12.t1).toBe(customItems.length);
              _context12.t2 = expect;
              _context12.next = 9;
              return driver.breadcrumbContentAt(0);
            case 9:
              _context12.t3 = _context12.sent;
              (0, _context12.t2)(_context12.t3).toBe(customItems[0].value);
              _context12.t4 = expect;
              _context12.next = 14;
              return driver.breadcrumbContentAt(1);
            case 14:
              _context12.t5 = _context12.sent;
              (0, _context12.t4)(_context12.t5).toBe(customItems[1].value);
            case 16:
            case "end":
              return _context12.stop();
          }
        }, _callee12);
      })));
      it('should render the customElement even if link attribute is given', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
        var _render13, driver;
        return _regeneratorRuntime.wrap(function _callee13$(_context13) {
          while (1) switch (_context13.prev = _context13.next) {
            case 0:
              _render13 = render(/*#__PURE__*/React.createElement(Breadcrumbs, {
                items: customItemsWithLinks,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 154,
                  columnNumber: 11
                }
              })), driver = _render13.driver;
              _context13.t0 = expect;
              _context13.next = 4;
              return driver.breadcrumbsLength();
            case 4:
              _context13.t1 = _context13.sent;
              (0, _context13.t0)(_context13.t1).toBe(customItemsWithLinks.length);
              _context13.t2 = expect;
              _context13.next = 9;
              return driver.breadcrumbContentAt(0);
            case 9:
              _context13.t3 = _context13.sent;
              (0, _context13.t2)(_context13.t3).toBe('Custom value');
            case 11:
            case "end":
              return _context13.stop();
          }
        }, _callee13);
      })));
      it('should render the value attribute of the item when this is the activeId', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
        var _render14, driver;
        return _regeneratorRuntime.wrap(function _callee14$(_context14) {
          while (1) switch (_context14.prev = _context14.next) {
            case 0:
              _render14 = render(/*#__PURE__*/React.createElement(Breadcrumbs, {
                items: customItemsWithLinks,
                activeId: 0,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 165,
                  columnNumber: 11
                }
              })), driver = _render14.driver;
              _context14.t0 = expect;
              _context14.next = 4;
              return driver.breadcrumbContentAt(0);
            case 4:
              _context14.t1 = _context14.sent;
              (0, _context14.t0)(_context14.t1).toBe(customItemsWithLinks[0].value);
            case 6:
            case "end":
              return _context14.stop();
          }
        }, _callee14);
      })));
    });
  }
});