"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _react = _interopRequireDefault(require("react"));
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
var _SearchUni = require("../Search.uni.driver");
var _Search = _interopRequireDefault(require("../Search"));
var _testUtils = require("../../utils/test-utils");
var _unit = require("../../utils/test-utils/unit");
var _react2 = require("@testing-library/react");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/Search/test/Search.spec.jsx";
describe('Search', function () {
  describe('[async]', function () {
    runTests((0, _unit.createRendererWithUniDriver)(_SearchUni.searchUniDriverFactory));
  });
  function runTests(render) {
    var _this = this;
    var REGEXP_SPECIAL_CHARS = '^$\\.*+?)(][}{|';
    var options = ['The quick', 'brown', 'fox', 'jumps over', 'the lazy', 'dog', REGEXP_SPECIAL_CHARS].map(function (value, index) {
      return {
        id: index,
        value: value
      };
    });
    var createDriver = function createDriver(jsx) {
      return render(jsx).driver;
    };
    afterEach(_unit.cleanup);
    describe('Controlled', function () {
      var ControlledSearch = (0, _testUtils.makeControlled)(_Search["default"]);
      var ControlledSearchOnBlur = function ControlledSearchOnBlur(_ref) {
        var valueOnBlur = _ref.valueOnBlur;
        var _React$useState = _react["default"].useState('fox'),
          _React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
          value = _React$useState2[0],
          setValue = _React$useState2[1];
        return /*#__PURE__*/_react["default"].createElement(_Search["default"], {
          expandable: true,
          value: value,
          onBlur: function onBlur() {
            return setValue(valueOnBlur);
          },
          __self: _this,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 42,
            columnNumber: 11
          }
        });
      };
      it('should show search options if initial value passed and down-key pressed', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
        var driver;
        return _regenerator["default"].wrap(function _callee$(_context) {
          while (1) switch (_context.prev = _context.next) {
            case 0:
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(ControlledSearch, {
                value: "the",
                options: options,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 52,
                  columnNumber: 11
                }
              }));
              _context.t0 = expect;
              _context.next = 4;
              return driver.dropdownLayoutDriver.isShown();
            case 4:
              _context.t1 = _context.sent;
              (0, _context.t0)(_context.t1).toBe(false);
              _context.next = 8;
              return driver.driver.pressKey('ArrowDown');
            case 8:
              _context.t2 = expect;
              _context.next = 11;
              return driver.dropdownLayoutDriver.isShown();
            case 11:
              _context.t3 = _context.sent;
              (0, _context.t2)(_context.t3).toBe(true);
            case 13:
            case "end":
              return _context.stop();
          }
        }, _callee);
      })));
      it('should not show search options when focusing empty input', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() {
        var driver;
        return _regenerator["default"].wrap(function _callee2$(_context2) {
          while (1) switch (_context2.prev = _context2.next) {
            case 0:
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(ControlledSearch, {
                options: options,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 61,
                  columnNumber: 37
                }
              }));
              _context2.t0 = expect;
              _context2.next = 4;
              return driver.dropdownLayoutDriver.isShown();
            case 4:
              _context2.t1 = _context2.sent;
              (0, _context2.t0)(_context2.t1).toBe(false);
              _context2.next = 8;
              return driver.inputDriver.focus();
            case 8:
              _context2.t2 = expect;
              _context2.next = 11;
              return driver.dropdownLayoutDriver.isShown();
            case 11:
              _context2.t3 = _context2.sent;
              (0, _context2.t2)(_context2.t3).toBe(false);
            case 13:
            case "end":
              return _context2.stop();
          }
        }, _callee2);
      })));
      it('should show search options when focusing empty input with showOptionsIfEmptyInput', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3() {
        var driver;
        return _regenerator["default"].wrap(function _callee3$(_context3) {
          while (1) switch (_context3.prev = _context3.next) {
            case 0:
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(ControlledSearch, {
                options: options,
                showOptionsIfEmptyInput: true,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 70,
                  columnNumber: 11
                }
              }));
              _context3.t0 = expect;
              _context3.next = 4;
              return driver.dropdownLayoutDriver.isShown();
            case 4:
              _context3.t1 = _context3.sent;
              (0, _context3.t0)(_context3.t1).toBe(false);
              _context3.next = 8;
              return driver.inputDriver.click();
            case 8:
              _context3.t2 = expect;
              _context3.next = 11;
              return driver.dropdownLayoutDriver.isShown();
            case 11:
              _context3.t3 = _context3.sent;
              (0, _context3.t2)(_context3.t3).toBe(true);
            case 13:
            case "end":
              return _context3.stop();
          }
        }, _callee3);
      })));
      it('should filter search options if initial input value passed and input focused', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4() {
        var driver;
        return _regenerator["default"].wrap(function _callee4$(_context4) {
          while (1) switch (_context4.prev = _context4.next) {
            case 0:
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(ControlledSearch, {
                options: options,
                value: "fox",
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 81,
                  columnNumber: 11
                }
              }));
              _context4.next = 3;
              return driver.inputDriver.focus();
            case 3:
              _context4.t0 = expect;
              _context4.next = 6;
              return driver.dropdownLayoutDriver.optionsLength();
            case 6:
              _context4.t1 = _context4.sent;
              (0, _context4.t0)(_context4.t1).toBe(1);
            case 8:
            case "end":
              return _context4.stop();
          }
        }, _callee4);
      })));
      it('should not treat spaces around search text as part of query', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5() {
        var driver;
        return _regenerator["default"].wrap(function _callee5$(_context5) {
          while (1) switch (_context5.prev = _context5.next) {
            case 0:
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(ControlledSearch, {
                options: options,
                value: "  fox  ",
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 90,
                  columnNumber: 11
                }
              }));
              _context5.next = 3;
              return driver.inputDriver.focus();
            case 3:
              _context5.t0 = expect;
              _context5.next = 6;
              return driver.dropdownLayoutDriver.optionsLength();
            case 6:
              _context5.t1 = _context5.sent;
              (0, _context5.t0)(_context5.t1).toBe(1);
            case 8:
            case "end":
              return _context5.stop();
          }
        }, _callee5);
      })));
      it('should render required elements of Search box', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6() {
        var driver;
        return _regenerator["default"].wrap(function _callee6$(_context6) {
          while (1) switch (_context6.prev = _context6.next) {
            case 0:
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(ControlledSearch, {
                options: options,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 98,
                  columnNumber: 37
                }
              }));
              _context6.t0 = expect;
              _context6.next = 4;
              return driver.inputDriver.hasPrefix();
            case 4:
              _context6.t1 = _context6.sent;
              (0, _context6.t0)(_context6.t1).toBe(true);
              _context6.t2 = expect;
              _context6.next = 9;
              return driver.inputDriver.getPlaceholder();
            case 9:
              _context6.t3 = _context6.sent;
              (0, _context6.t2)(_context6.t3).toBe('Search');
              _context6.t4 = expect;
              _context6.next = 14;
              return driver.inputDriver.hasMenuArrow();
            case 14:
              _context6.t5 = _context6.sent;
              (0, _context6.t4)(_context6.t5).toBe(false);
            case 16:
            case "end":
              return _context6.stop();
          }
        }, _callee6);
      })));
      it('should not render clear text button if clearButton=false', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7() {
        var driver;
        return _regenerator["default"].wrap(function _callee7$(_context7) {
          while (1) switch (_context7.prev = _context7.next) {
            case 0:
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(ControlledSearch, {
                options: options,
                clearButton: false,
                value: "fox",
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 107,
                  columnNumber: 11
                }
              }));
              _context7.t0 = expect;
              _context7.next = 4;
              return driver.inputDriver.hasClearButton();
            case 4:
              _context7.t1 = _context7.sent;
              (0, _context7.t0)(_context7.t1).toBe(false);
            case 6:
            case "end":
              return _context7.stop();
          }
        }, _callee7);
      })));
      it('should render clear text button if input is not empty', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee8() {
        var driver;
        return _regenerator["default"].wrap(function _callee8$(_context8) {
          while (1) switch (_context8.prev = _context8.next) {
            case 0:
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(ControlledSearch, {
                options: options,
                value: "fox",
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 119,
                  columnNumber: 11
                }
              }));
              _context8.t0 = expect;
              _context8.next = 4;
              return driver.inputDriver.hasClearButton();
            case 4:
              _context8.t1 = _context8.sent;
              (0, _context8.t0)(_context8.t1).toBe(true);
            case 6:
            case "end":
              return _context8.stop();
          }
        }, _callee8);
      })));
      it('should remain focused on Search component after clear button click', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee9() {
        var driver;
        return _regenerator["default"].wrap(function _callee9$(_context9) {
          while (1) switch (_context9.prev = _context9.next) {
            case 0:
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(ControlledSearch, {
                options: options,
                value: "fox",
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 127,
                  columnNumber: 11
                }
              }));
              _context9.next = 3;
              return driver.inputDriver.clickClear();
            case 3:
              _context9.t0 = expect;
              _context9.next = 6;
              return driver.inputDriver.isFocus();
            case 6:
              _context9.t1 = _context9.sent;
              (0, _context9.t0)(_context9.t1).toBe(true);
            case 8:
            case "end":
              return _context9.stop();
          }
        }, _callee9);
      })));

      //TODO: missing implementation
      it.skip('should collapse search options after clear button click', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee0() {
        var driver;
        return _regenerator["default"].wrap(function _callee0$(_context0) {
          while (1) switch (_context0.prev = _context0.next) {
            case 0:
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(ControlledSearch, {
                options: options,
                value: "fox",
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 137,
                  columnNumber: 11
                }
              }));
              _context0.next = 3;
              return driver.inputDriver.clickClear();
            case 3:
              _context0.t0 = expect;
              _context0.next = 6;
              return driver.dropdownLayoutDriver.isShown();
            case 6:
              _context0.t1 = _context0.sent;
              (0, _context0.t0)(_context0.t1).toBe(false);
            case 8:
            case "end":
              return _context0.stop();
          }
        }, _callee0);
      })));
      it('should do search when text was entered', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee1() {
        var driver;
        return _regenerator["default"].wrap(function _callee1$(_context1) {
          while (1) switch (_context1.prev = _context1.next) {
            case 0:
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(ControlledSearch, {
                options: options,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 145,
                  columnNumber: 37
                }
              }));
              _context1.next = 3;
              return driver.inputDriver.focus();
            case 3:
              _context1.next = 5;
              return driver.inputDriver.enterText('fox');
            case 5:
              _context1.t0 = expect;
              _context1.next = 8;
              return driver.dropdownLayoutDriver.optionsLength();
            case 8:
              _context1.t1 = _context1.sent;
              (0, _context1.t0)(_context1.t1).toBe(1);
              _context1.next = 12;
              return driver.inputDriver.clearText();
            case 12:
              _context1.next = 14;
              return driver.inputDriver.enterText('the');
            case 14:
              _context1.t2 = expect;
              _context1.next = 17;
              return driver.dropdownLayoutDriver.optionsLength();
            case 17:
              _context1.t3 = _context1.sent;
              (0, _context1.t2)(_context1.t3).toBe(2);
              _context1.next = 21;
              return driver.inputDriver.clearText();
            case 21:
              _context1.next = 23;
              return driver.inputDriver.enterText('');
            case 23:
              _context1.t4 = expect;
              _context1.next = 26;
              return driver.dropdownLayoutDriver.optionsLength();
            case 26:
              _context1.t5 = _context1.sent;
              (0, _context1.t4)(_context1.t5).toBe(options.length);
            case 28:
            case "end":
              return _context1.stop();
          }
        }, _callee1);
      })));
      it('should treat regex characters as text', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee10() {
        var driver;
        return _regenerator["default"].wrap(function _callee10$(_context10) {
          while (1) switch (_context10.prev = _context10.next) {
            case 0:
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(ControlledSearch, {
                options: options,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 161,
                  columnNumber: 37
                }
              }));
              _context10.next = 3;
              return driver.inputDriver.focus();
            case 3:
              _context10.next = 5;
              return driver.inputDriver.enterText(REGEXP_SPECIAL_CHARS);
            case 5:
              _context10.t0 = expect;
              _context10.next = 8;
              return driver.dropdownLayoutDriver.optionsLength();
            case 8:
              _context10.t1 = _context10.sent;
              (0, _context10.t0)(_context10.t1).toBe(1);
            case 10:
            case "end":
              return _context10.stop();
          }
        }, _callee10);
      })));
      it('should show no results if nothing was found in options', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee11() {
        var driver;
        return _regenerator["default"].wrap(function _callee11$(_context11) {
          while (1) switch (_context11.prev = _context11.next) {
            case 0:
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(ControlledSearch, {
                options: options,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 169,
                  columnNumber: 37
                }
              }));
              _context11.next = 3;
              return driver.inputDriver.focus();
            case 3:
              _context11.next = 5;
              return driver.inputDriver.enterText('option nowhere to be found');
            case 5:
              _context11.t0 = expect;
              _context11.next = 8;
              return driver.dropdownLayoutDriver.optionsLength();
            case 8:
              _context11.t1 = _context11.sent;
              (0, _context11.t0)(_context11.t1).toBe(0);
            case 10:
            case "end":
              return _context11.stop();
          }
        }, _callee11);
      })));

      // TODO: enhance Input component
      it.skip('should focus search input if click on magnifying glass', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee12() {
        var driver;
        return _regenerator["default"].wrap(function _callee12$(_context12) {
          while (1) switch (_context12.prev = _context12.next) {
            case 0:
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(ControlledSearch, {
                options: options,
                value: "fox",
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 179,
                  columnNumber: 11
                }
              }));
              _context12.t0 = expect;
              _context12.next = 4;
              return driver.inputDriver.hasPrefix();
            case 4:
              _context12.t1 = _context12.sent;
              (0, _context12.t0)(_context12.t1).toBe(true);
              _context12.t2 = expect;
              _context12.next = 9;
              return driver.inputDriver.isFocus();
            case 9:
              _context12.t3 = _context12.sent;
              (0, _context12.t2)(_context12.t3).toBe(true);
            case 11:
            case "end":
              return _context12.stop();
          }
        }, _callee12);
      })));
      it('should allow filtering options by predicate', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee13() {
        var nodeOptions, predicate, driver;
        return _regenerator["default"].wrap(function _callee13$(_context13) {
          while (1) switch (_context13.prev = _context13.next) {
            case 0:
              nodeOptions = [{
                id: 1,
                value: /*#__PURE__*/_react["default"].createElement("div", {
                  __self: _this,
                  __source: {
                    fileName: _jsxFileName,
                    lineNumber: 189,
                    columnNumber: 27
                  }
                }, "Found me"),
                keywords: ['Found']
              }, {
                id: 2,
                value: /*#__PURE__*/_react["default"].createElement("div", {
                  __self: _this,
                  __source: {
                    fileName: _jsxFileName,
                    lineNumber: 190,
                    columnNumber: 27
                  }
                }, "Filtered me"),
                keywords: ['Filtered']
              }];
              predicate = vi.fn(function (option) {
                return option.keywords.includes('Found');
              });
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(ControlledSearch, {
                options: nodeOptions,
                predicate: predicate,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 196,
                  columnNumber: 11
                }
              }));
              _context13.next = 5;
              return driver.inputDriver.enterText('Some text value');
            case 5:
              expect(predicate).toHaveBeenCalled();
              _context13.t0 = expect;
              _context13.next = 9;
              return driver.dropdownLayoutDriver.optionsLength();
            case 9:
              _context13.t1 = _context13.sent;
              (0, _context13.t0)(_context13.t1).toBe(1);
            case 11:
            case "end":
              return _context13.stop();
          }
        }, _callee13);
      })));
      it('should highlight the matched options text', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee14() {
        var driver;
        return _regenerator["default"].wrap(function _callee14$(_context14) {
          while (1) switch (_context14.prev = _context14.next) {
            case 0:
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(ControlledSearch, {
                value: "the",
                options: options,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 205,
                  columnNumber: 11
                }
              }));
              _context14.t0 = expect;
              _context14.next = 4;
              return driver.dropdownLayoutDriver.optionContentAt(0);
            case 4:
              _context14.t1 = _context14.sent;
              (0, _context14.t0)(_context14.t1).toContain('The');
            case 6:
            case "end":
              return _context14.stop();
          }
        }, _callee14);
      })));
      it('should collapse when out of focus if value in onBlur() is set to empty', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee15() {
        var _createDriver, driver, inputDriver;
        return _regenerator["default"].wrap(function _callee15$(_context15) {
          while (1) switch (_context15.prev = _context15.next) {
            case 0:
              _createDriver = createDriver(/*#__PURE__*/_react["default"].createElement(ControlledSearchOnBlur, {
                valueOnBlur: "",
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 215,
                  columnNumber: 11
                }
              })), driver = _createDriver.driver, inputDriver = _createDriver.inputDriver;
              _context15.next = 3;
              return inputDriver.click();
            case 3:
              _context15.next = 5;
              return inputDriver.enterText('fox');
            case 5:
              _context15.next = 7;
              return inputDriver.blur();
            case 7:
              _context15.t0 = expect;
              _context15.next = 10;
              return inputDriver.getText();
            case 10:
              _context15.t1 = _context15.sent;
              (0, _context15.t0)(_context15.t1).toEqual('');
              _context15.t2 = expect;
              _context15.next = 15;
              return driver.isCollapsed();
            case 15:
              _context15.t3 = _context15.sent;
              (0, _context15.t2)(_context15.t3).toBe(true);
            case 17:
            case "end":
              return _context15.stop();
          }
        }, _callee15);
      })));
      it('should not collapse when out of focus if value is set to custom in onBlur()', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee16() {
        var _createDriver2, driver, inputDriver;
        return _regenerator["default"].wrap(function _callee16$(_context16) {
          while (1) switch (_context16.prev = _context16.next) {
            case 0:
              _createDriver2 = createDriver(/*#__PURE__*/_react["default"].createElement(ControlledSearchOnBlur, {
                valueOnBlur: "wix",
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 226,
                  columnNumber: 11
                }
              })), driver = _createDriver2.driver, inputDriver = _createDriver2.inputDriver;
              _context16.next = 3;
              return inputDriver.click();
            case 3:
              _context16.next = 5;
              return inputDriver.enterText('');
            case 5:
              _context16.next = 7;
              return inputDriver.blur();
            case 7:
              _context16.t0 = expect;
              _context16.next = 10;
              return inputDriver.getText();
            case 10:
              _context16.t1 = _context16.sent;
              (0, _context16.t0)(_context16.t1).toEqual('wix');
              _context16.t2 = expect;
              _context16.next = 15;
              return driver.isCollapsed();
            case 15:
              _context16.t3 = _context16.sent;
              (0, _context16.t2)(_context16.t3).toBe(false);
            case 17:
            case "end":
              return _context16.stop();
          }
        }, _callee16);
      })));
      it('should not collapse when clicked onClear() if value is set to custom in onBlur()', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee17() {
        var _createDriver3, driver, inputDriver;
        return _regenerator["default"].wrap(function _callee17$(_context17) {
          while (1) switch (_context17.prev = _context17.next) {
            case 0:
              _createDriver3 = createDriver(/*#__PURE__*/_react["default"].createElement(ControlledSearchOnBlur, {
                valueOnBlur: "wix",
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 237,
                  columnNumber: 11
                }
              })), driver = _createDriver3.driver, inputDriver = _createDriver3.inputDriver;
              _context17.next = 3;
              return inputDriver.clickClear();
            case 3:
              _context17.t0 = expect;
              _context17.next = 6;
              return inputDriver.getText();
            case 6:
              _context17.t1 = _context17.sent;
              (0, _context17.t0)(_context17.t1).toEqual('fox');
              _context17.t2 = expect;
              _context17.next = 11;
              return driver.isCollapsed();
            case 11:
              _context17.t3 = _context17.sent;
              (0, _context17.t2)(_context17.t3).toBe(false);
            case 13:
            case "end":
              return _context17.stop();
          }
        }, _callee17);
      })));
      it('should show empty state node when no options are available', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee18() {
        var driver;
        return _regenerator["default"].wrap(function _callee18$(_context18) {
          while (1) switch (_context18.prev = _context18.next) {
            case 0:
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(ControlledSearch, {
                options: [],
                value: "fox",
                renderEmptyState: function renderEmptyState(value) {
                  return /*#__PURE__*/_react["default"].createElement("div", {
                    __self: _this,
                    __source: {
                      fileName: _jsxFileName,
                      lineNumber: 250,
                      columnNumber: 40
                    }
                  }, "No results for ", value);
                },
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 247,
                  columnNumber: 11
                }
              }));
              _context18.next = 3;
              return driver.inputDriver.click();
            case 3:
              expect(_unit.screen.getByText('No results for fox')).toBeTruthy();
            case 4:
            case "end":
              return _context18.stop();
          }
        }, _callee18);
      })));
      it('should NOT show empty state node when options are available', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee19() {
        var driver;
        return _regenerator["default"].wrap(function _callee19$(_context19) {
          while (1) switch (_context19.prev = _context19.next) {
            case 0:
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(ControlledSearch, {
                options: [{
                  id: 1,
                  value: 'fox'
                }, {
                  id: 2,
                  value: 'dog'
                }],
                value: "fox",
                renderEmptyState: function renderEmptyState(value) {
                  return /*#__PURE__*/_react["default"].createElement("div", {
                    __self: _this,
                    __source: {
                      fileName: _jsxFileName,
                      lineNumber: 265,
                      columnNumber: 40
                    }
                  }, "No results for ", value);
                },
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 259,
                  columnNumber: 11
                }
              }));
              _context19.next = 3;
              return driver.inputDriver.click();
            case 3:
              expect(_unit.screen.queryByText('No results for fox')).toBeFalsy();
            case 4:
            case "end":
              return _context19.stop();
          }
        }, _callee19);
      })));
      describe('Clearing input', function () {
        it('should NOT trigger onChange on clearing', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee20() {
          var onChange, _createDriver4, inputDriver;
          return _regenerator["default"].wrap(function _callee20$(_context20) {
            while (1) switch (_context20.prev = _context20.next) {
              case 0:
                onChange = vi.fn();
                _createDriver4 = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                  value: "fox",
                  onChange: onChange,
                  clearButton: true,
                  __self: _this,
                  __source: {
                    fileName: _jsxFileName,
                    lineNumber: 276,
                    columnNumber: 13
                  }
                })), inputDriver = _createDriver4.inputDriver;
                expect(onChange).toHaveBeenCalledTimes(0);
                _context20.next = 5;
                return inputDriver.clickClear();
              case 5:
                expect(onChange).toHaveBeenCalledTimes(0);
              case 6:
              case "end":
                return _context20.stop();
            }
          }, _callee20);
        })));
        it('should trigger onClear on clearing', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee21() {
          var onClear, _createDriver5, inputDriver;
          return _regenerator["default"].wrap(function _callee21$(_context21) {
            while (1) switch (_context21.prev = _context21.next) {
              case 0:
                onClear = vi.fn();
                _createDriver5 = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                  options: options,
                  value: "fox",
                  onChange: function onChange() {},
                  clearButton: true,
                  onClear: onClear,
                  __self: _this,
                  __source: {
                    fileName: _jsxFileName,
                    lineNumber: 286,
                    columnNumber: 13
                  }
                })), inputDriver = _createDriver5.inputDriver;
                expect(onClear).toHaveBeenCalledTimes(0);
                _context21.next = 5;
                return inputDriver.clickClear();
              case 5:
                expect(onClear).toHaveBeenCalledTimes(1);
                expect(onClear.mock.calls[0][0]).toBeTruthy();
              case 7:
              case "end":
                return _context21.stop();
            }
          }, _callee21);
        })));
      });
    });
    describe('Uncontrolled', function () {
      it('should filter search options if initial defaultValue value passed and input focused', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee22() {
        var _createDriver6, inputDriver, dropdownLayoutDriver;
        return _regenerator["default"].wrap(function _callee22$(_context22) {
          while (1) switch (_context22.prev = _context22.next) {
            case 0:
              _createDriver6 = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                options: options,
                defaultValue: "fox",
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 305,
                  columnNumber: 11
                }
              })), inputDriver = _createDriver6.inputDriver, dropdownLayoutDriver = _createDriver6.dropdownLayoutDriver;
              _context22.next = 3;
              return inputDriver.focus();
            case 3:
              _context22.t0 = expect;
              _context22.next = 6;
              return dropdownLayoutDriver.optionsLength();
            case 6:
              _context22.t1 = _context22.sent;
              (0, _context22.t0)(_context22.t1).toBe(1);
            case 8:
            case "end":
              return _context22.stop();
          }
        }, _callee22);
      })));
      describe('Clearing input', function () {
        it('should trigger onClear on clearing', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee23() {
          var onClear, _createDriver7, inputDriver;
          return _regenerator["default"].wrap(function _callee23$(_context23) {
            while (1) switch (_context23.prev = _context23.next) {
              case 0:
                onClear = vi.fn();
                _createDriver7 = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                  defaultValue: "fox",
                  options: options,
                  onClear: onClear,
                  __self: _this,
                  __source: {
                    fileName: _jsxFileName,
                    lineNumber: 316,
                    columnNumber: 13
                  }
                })), inputDriver = _createDriver7.inputDriver;
                expect(onClear).toHaveBeenCalledTimes(0);
                _context23.next = 5;
                return inputDriver.clickClear();
              case 5:
                expect(onClear).toHaveBeenCalledTimes(1);
                expect(onClear.mock.calls[0][0]).toBeTruthy();
              case 7:
              case "end":
                return _context23.stop();
            }
          }, _callee23);
        })));
        it('should clear input after clear button click', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee24() {
          var _createDriver8, inputDriver;
          return _regenerator["default"].wrap(function _callee24$(_context24) {
            while (1) switch (_context24.prev = _context24.next) {
              case 0:
                _createDriver8 = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                  defaultValue: "fox",
                  options: options,
                  __self: _this,
                  __source: {
                    fileName: _jsxFileName,
                    lineNumber: 326,
                    columnNumber: 13
                  }
                })), inputDriver = _createDriver8.inputDriver;
                _context24.next = 3;
                return inputDriver.enterText('h');
              case 3:
                _context24.t0 = expect;
                _context24.next = 6;
                return inputDriver.getText();
              case 6:
                _context24.t1 = _context24.sent;
                (0, _context24.t0)(_context24.t1).toEqual('h');
                _context24.next = 10;
                return inputDriver.clickClear();
              case 10:
                _context24.t2 = expect;
                _context24.next = 13;
                return inputDriver.getText();
              case 13:
                _context24.t3 = _context24.sent;
                (0, _context24.t2)(_context24.t3).toEqual('');
              case 15:
              case "end":
                return _context24.stop();
            }
          }, _callee24);
        })));
      });
    });
    describe('Expandable', function () {
      it('should start as collapsed element by default when expandable=true', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee25() {
        var _createDriver9, driver;
        return _regenerator["default"].wrap(function _callee25$(_context25) {
          while (1) switch (_context25.prev = _context25.next) {
            case 0:
              _createDriver9 = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                options: options,
                expandable: true,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 339,
                  columnNumber: 11
                }
              })), driver = _createDriver9.driver;
              _context25.t0 = expect;
              _context25.next = 4;
              return driver.isExpandable();
            case 4:
              _context25.t1 = _context25.sent;
              (0, _context25.t0)(_context25.t1).toBe(true);
              _context25.t2 = expect;
              _context25.next = 9;
              return driver.isCollapsed();
            case 9:
              _context25.t3 = _context25.sent;
              (0, _context25.t2)(_context25.t3).toBe(true);
            case 11:
            case "end":
              return _context25.stop();
          }
        }, _callee25);
      })));
      it('should extend the search input when clicked', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee26() {
        var _createDriver0, driver, inputDriver;
        return _regenerator["default"].wrap(function _callee26$(_context26) {
          while (1) switch (_context26.prev = _context26.next) {
            case 0:
              _createDriver0 = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                options: options,
                expandable: true,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 348,
                  columnNumber: 11
                }
              })), driver = _createDriver0.driver, inputDriver = _createDriver0.inputDriver;
              _context26.t0 = expect;
              _context26.next = 4;
              return driver.isCollapsed();
            case 4:
              _context26.t1 = _context26.sent;
              (0, _context26.t0)(_context26.t1).toBe(true);
              _context26.next = 8;
              return inputDriver.click();
            case 8:
              _context26.t2 = expect;
              _context26.next = 11;
              return driver.isCollapsed();
            case 11:
              _context26.t3 = _context26.sent;
              (0, _context26.t2)(_context26.t3).toBe(false);
            case 13:
            case "end":
              return _context26.stop();
          }
        }, _callee26);
      })));
      it('should be focused on the input after expanding the search component', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee27() {
        var _createDriver1, inputDriver;
        return _regenerator["default"].wrap(function _callee27$(_context27) {
          while (1) switch (_context27.prev = _context27.next) {
            case 0:
              _createDriver1 = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                options: options,
                expandable: true,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 358,
                  columnNumber: 11
                }
              })), inputDriver = _createDriver1.inputDriver;
              _context27.t0 = expect;
              _context27.next = 4;
              return inputDriver.isFocus();
            case 4:
              _context27.t1 = _context27.sent;
              (0, _context27.t0)(_context27.t1).toBe(false);
              _context27.next = 8;
              return inputDriver.click();
            case 8:
              _context27.t2 = expect;
              _context27.next = 11;
              return inputDriver.isFocus();
            case 11:
              _context27.t3 = _context27.sent;
              (0, _context27.t2)(_context27.t3).toBe(true);
            case 13:
            case "end":
              return _context27.stop();
          }
        }, _callee27);
      })));
      it('should not collapse the input if the input has value and blurred', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee28() {
        var _createDriver10, inputDriver, driver;
        return _regenerator["default"].wrap(function _callee28$(_context28) {
          while (1) switch (_context28.prev = _context28.next) {
            case 0:
              _createDriver10 = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                options: options,
                expandable: true,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 368,
                  columnNumber: 11
                }
              })), inputDriver = _createDriver10.inputDriver, driver = _createDriver10.driver;
              _context28.next = 3;
              return inputDriver.click();
            case 3:
              _context28.next = 5;
              return inputDriver.enterText('wix');
            case 5:
              _context28.next = 7;
              return inputDriver.blur();
            case 7:
              _context28.t0 = expect;
              _context28.next = 10;
              return driver.isCollapsed();
            case 10:
              _context28.t1 = _context28.sent;
              (0, _context28.t0)(_context28.t1).toBe(false);
            case 12:
            case "end":
              return _context28.stop();
          }
        }, _callee28);
      })));
      it('should collapse the input if the input has no value and blurred', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee29() {
        var _createDriver11, inputDriver, driver;
        return _regenerator["default"].wrap(function _callee29$(_context29) {
          while (1) switch (_context29.prev = _context29.next) {
            case 0:
              _createDriver11 = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                options: options,
                expandable: true,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 379,
                  columnNumber: 11
                }
              })), inputDriver = _createDriver11.inputDriver, driver = _createDriver11.driver;
              _context29.next = 3;
              return inputDriver.click();
            case 3:
              _context29.next = 5;
              return inputDriver.blur();
            case 5:
              _context29.t0 = expect;
              _context29.next = 8;
              return driver.isCollapsed();
            case 8:
              _context29.t1 = _context29.sent;
              (0, _context29.t0)(_context29.t1).toBe(true);
            case 10:
            case "end":
              return _context29.stop();
          }
        }, _callee29);
      })));
      it('should have non-collapsed input when expandable=true and the input has initial value', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee30() {
        var _createDriver12, driver;
        return _regenerator["default"].wrap(function _callee30$(_context30) {
          while (1) switch (_context30.prev = _context30.next) {
            case 0:
              _createDriver12 = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                options: options,
                expandable: true,
                defaultValue: "Test",
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 389,
                  columnNumber: 11
                }
              })), driver = _createDriver12.driver;
              _context30.t0 = expect;
              _context30.next = 4;
              return driver.isExpandable();
            case 4:
              _context30.t1 = _context30.sent;
              (0, _context30.t0)(_context30.t1).toBe(true);
              _context30.t2 = expect;
              _context30.next = 9;
              return driver.isCollapsed();
            case 9:
              _context30.t3 = _context30.sent;
              (0, _context30.t2)(_context30.t3).toBe(false);
            case 11:
            case "end":
              return _context30.stop();
          }
        }, _callee30);
      })));
      it('should not be collapsed by default', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee31() {
        var _createDriver13, driver, inputDriver;
        return _regenerator["default"].wrap(function _callee31$(_context31) {
          while (1) switch (_context31.prev = _context31.next) {
            case 0:
              _createDriver13 = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                options: options,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 398,
                  columnNumber: 11
                }
              })), driver = _createDriver13.driver, inputDriver = _createDriver13.inputDriver;
              _context31.t0 = expect;
              _context31.next = 4;
              return driver.isExpandable();
            case 4:
              _context31.t1 = _context31.sent;
              (0, _context31.t0)(_context31.t1).toBe(false);
              _context31.t2 = expect;
              _context31.next = 9;
              return driver.isCollapsed();
            case 9:
              _context31.t3 = _context31.sent;
              (0, _context31.t2)(_context31.t3).toBe(false);
              _context31.next = 13;
              return inputDriver.click();
            case 13:
              _context31.t4 = expect;
              _context31.next = 16;
              return driver.isCollapsed();
            case 16:
              _context31.t5 = _context31.sent;
              (0, _context31.t4)(_context31.t5).toBe(false);
            case 18:
            case "end":
              return _context31.stop();
          }
        }, _callee31);
      })));
      it('should not be collapsed when specified with autoFocus', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee32() {
        var _createDriver14, driver;
        return _regenerator["default"].wrap(function _callee32$(_context32) {
          while (1) switch (_context32.prev = _context32.next) {
            case 0:
              _createDriver14 = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                expandable: true,
                autoFocus: true,
                options: options,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 408,
                  columnNumber: 11
                }
              })), driver = _createDriver14.driver;
              _context32.t0 = expect;
              _context32.next = 4;
              return driver.isExpandable();
            case 4:
              _context32.t1 = _context32.sent;
              (0, _context32.t0)(_context32.t1).toBe(true);
              _context32.t2 = expect;
              _context32.next = 9;
              return driver.isCollapsed();
            case 9:
              _context32.t3 = _context32.sent;
              (0, _context32.t2)(_context32.t3).toBe(false);
            case 11:
            case "end":
              return _context32.stop();
          }
        }, _callee32);
      })));
    });
    describe('debounced', function () {
      beforeEach(function () {
        vi.useFakeTimers();
      });
      afterEach(function () {
        vi.useRealTimers();
      });
      it('should debounce onChange callback if debounceMs prop is provided', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee36() {
        var onChangeSpy, driver;
        return _regenerator["default"].wrap(function _callee36$(_context36) {
          while (1) switch (_context36.prev = _context36.next) {
            case 0:
              onChangeSpy = vi.fn();
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                onChange: onChangeSpy,
                debounceMs: 100,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 428,
                  columnNumber: 11
                }
              }));
              _context36.next = 4;
              return driver.inputDriver.enterText('f');
            case 4:
              _context36.next = 6;
              return (0, _unit.act)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee33() {
                return _regenerator["default"].wrap(function _callee33$(_context33) {
                  while (1) switch (_context33.prev = _context33.next) {
                    case 0:
                      return _context33.abrupt("return", vi.advanceTimersByTime(99));
                    case 1:
                    case "end":
                      return _context33.stop();
                  }
                }, _callee33);
              })));
            case 6:
              expect(onChangeSpy).not.toHaveBeenCalled();
              _context36.next = 9;
              return driver.inputDriver.enterText('fo');
            case 9:
              _context36.next = 11;
              return (0, _unit.act)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee34() {
                return _regenerator["default"].wrap(function _callee34$(_context34) {
                  while (1) switch (_context34.prev = _context34.next) {
                    case 0:
                      return _context34.abrupt("return", vi.advanceTimersByTime(99));
                    case 1:
                    case "end":
                      return _context34.stop();
                  }
                }, _callee34);
              })));
            case 11:
              expect(onChangeSpy).not.toHaveBeenCalled();
              _context36.next = 14;
              return driver.inputDriver.enterText('foo');
            case 14:
              _context36.next = 16;
              return (0, _unit.act)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee35() {
                return _regenerator["default"].wrap(function _callee35$(_context35) {
                  while (1) switch (_context35.prev = _context35.next) {
                    case 0:
                      return _context35.abrupt("return", vi.advanceTimersByTime(100));
                    case 1:
                    case "end":
                      return _context35.stop();
                  }
                }, _callee35);
              })));
            case 16:
              expect(onChangeSpy).toHaveBeenCalledTimes(1);
              expect(onChangeSpy.mock.calls[0][0].target.value).toBe('foo');
            case 18:
            case "end":
              return _context36.stop();
          }
        }, _callee36);
      })));
      it('should not debounce onChange callback if debounceMs prop is not provided', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee39() {
        var onChangeSpy, driver;
        return _regenerator["default"].wrap(function _callee39$(_context39) {
          while (1) switch (_context39.prev = _context39.next) {
            case 0:
              onChangeSpy = vi.fn();
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                onChange: onChangeSpy,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 450,
                  columnNumber: 37
                }
              }));
              _context39.next = 4;
              return driver.inputDriver.enterText('f');
            case 4:
              expect(onChangeSpy).toHaveBeenCalledTimes(1);
              expect(onChangeSpy.mock.calls[0][0].target.value).toBe('f');
              _context39.next = 8;
              return driver.inputDriver.enterText('fo');
            case 8:
              _context39.next = 10;
              return (0, _unit.act)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee37() {
                return _regenerator["default"].wrap(function _callee37$(_context37) {
                  while (1) switch (_context37.prev = _context37.next) {
                    case 0:
                      return _context37.abrupt("return", vi.advanceTimersByTime(99));
                    case 1:
                    case "end":
                      return _context37.stop();
                  }
                }, _callee37);
              })));
            case 10:
              expect(onChangeSpy).toHaveBeenCalledTimes(2);
              expect(onChangeSpy.mock.calls[1][0].target.value).toBe('fo');
              _context39.next = 14;
              return driver.inputDriver.enterText('foo');
            case 14:
              _context39.next = 16;
              return (0, _unit.act)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee38() {
                return _regenerator["default"].wrap(function _callee38$(_context38) {
                  while (1) switch (_context38.prev = _context38.next) {
                    case 0:
                      return _context38.abrupt("return", vi.advanceTimersByTime(100));
                    case 1:
                    case "end":
                      return _context38.stop();
                  }
                }, _callee38);
              })));
            case 16:
              expect(onChangeSpy).toHaveBeenCalledTimes(3);
              expect(onChangeSpy.mock.calls[2][0].target.value).toBe('foo');
            case 18:
            case "end":
              return _context39.stop();
          }
        }, _callee39);
      })));

      // TODO - missing implementation close dropdown on clear button press.
      it.skip('dropdown should not open until debounce finishes', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee41() {
        var onChangeSpy, driver;
        return _regenerator["default"].wrap(function _callee41$(_context41) {
          while (1) switch (_context41.prev = _context41.next) {
            case 0:
              onChangeSpy = vi.fn();
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                options: options,
                onChange: onChangeSpy,
                debounceMs: 100,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 474,
                  columnNumber: 11
                }
              }));
              _context41.next = 4;
              return driver.inputDriver.enterText('z');
            case 4:
              _context41.t0 = expect;
              _context41.next = 7;
              return driver.dropdownLayoutDriver.isShown();
            case 7:
              _context41.t1 = _context41.sent;
              (0, _context41.t0)(_context41.t1).toBe(false);
              _context41.next = 11;
              return (0, _unit.act)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee40() {
                return _regenerator["default"].wrap(function _callee40$(_context40) {
                  while (1) switch (_context40.prev = _context40.next) {
                    case 0:
                      vi.advanceTimersByTime(100);
                    case 1:
                    case "end":
                      return _context40.stop();
                  }
                }, _callee40);
              })));
            case 11:
              _context41.t2 = expect;
              _context41.next = 14;
              return driver.dropdownLayoutDriver.isShown();
            case 14:
              _context41.t3 = _context41.sent;
              (0, _context41.t2)(_context41.t3).toBe(true);
            case 16:
            case "end":
              return _context41.stop();
          }
        }, _callee41);
      })));
    });
    describe('status attribute', function () {
      it('should have no status', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee42() {
        var _createDriver15, inputDriver;
        return _regenerator["default"].wrap(function _callee42$(_context42) {
          while (1) switch (_context42.prev = _context42.next) {
            case 0:
              _createDriver15 = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 489,
                  columnNumber: 46
                }
              })), inputDriver = _createDriver15.inputDriver;
              _context42.t0 = expect;
              _context42.next = 4;
              return inputDriver.hasStatus('error');
            case 4:
              _context42.t1 = _context42.sent;
              (0, _context42.t0)(_context42.t1).toBe(false);
            case 6:
            case "end":
              return _context42.stop();
          }
        }, _callee42);
      })));
      it.each([{
        status: 'error'
      }, {
        status: 'warning'
      }, {
        status: 'loading'
      }])('should display status when %p', /*#__PURE__*/function () {
        var _ref44 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee43(test) {
          var _createDriver16, inputDriver;
          return _regenerator["default"].wrap(function _callee43$(_context43) {
            while (1) switch (_context43.prev = _context43.next) {
              case 0:
                _createDriver16 = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], (0, _extends2["default"])({}, test, {
                  __self: _this,
                  __source: {
                    fileName: _jsxFileName,
                    lineNumber: 499,
                    columnNumber: 46
                  }
                }))), inputDriver = _createDriver16.inputDriver;
                _context43.t0 = expect;
                _context43.next = 4;
                return inputDriver.hasStatus(test.status);
              case 4:
                _context43.t1 = _context43.sent;
                (0, _context43.t0)(_context43.t1).toBe(true);
              case 6:
              case "end":
                return _context43.stop();
            }
          }, _callee43);
        }));
        return function (_x) {
          return _ref44.apply(this, arguments);
        };
      }());
      it.each([{
        status: 'error',
        statusMessage: 'Error Message'
      }, {
        status: 'warning',
        statusMessage: 'Warning Message'
      }, {
        status: 'loading',
        statusMessage: 'Loading Message'
      }])('should display status with message when %p', /*#__PURE__*/function () {
        var _ref45 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee44(test) {
          var _createDriver17, inputDriver;
          return _regenerator["default"].wrap(function _callee44$(_context44) {
            while (1) switch (_context44.prev = _context44.next) {
              case 0:
                _createDriver17 = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], (0, _extends2["default"])({}, test, {
                  __self: _this,
                  __source: {
                    fileName: _jsxFileName,
                    lineNumber: 509,
                    columnNumber: 46
                  }
                }))), inputDriver = _createDriver17.inputDriver;
                _context44.t0 = expect;
                _context44.next = 4;
                return inputDriver.hasStatus(test.status);
              case 4:
                _context44.t1 = _context44.sent;
                (0, _context44.t0)(_context44.t1).toBe(true);
                _context44.t2 = expect;
                _context44.next = 9;
                return inputDriver.getStatusMessage();
              case 9:
                _context44.t3 = _context44.sent;
                (0, _context44.t2)(_context44.t3).toBe(test.statusMessage);
              case 11:
              case "end":
                return _context44.stop();
            }
          }, _callee44);
        }));
        return function (_x2) {
          return _ref45.apply(this, arguments);
        };
      }());
      it('should call onEnterPressed', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee45() {
        var onEnterPressed, _createDriver18, inputDriver;
        return _regenerator["default"].wrap(function _callee45$(_context45) {
          while (1) switch (_context45.prev = _context45.next) {
            case 0:
              onEnterPressed = vi.fn();
              _createDriver18 = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                onEnterPressed: onEnterPressed,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 518,
                  columnNumber: 11
                }
              })), inputDriver = _createDriver18.inputDriver;
              expect(onEnterPressed).not.toHaveBeenCalled();

              // Driver
              _context45.next = 5;
              return inputDriver.keyDown({
                key: 'Enter',
                keyCode: 13
              });
            case 5:
              _context45.next = 7;
              return inputDriver.keyDown('Enter');
            case 7:
              expect(onEnterPressed).toHaveBeenCalled();
            case 8:
            case "end":
              return _context45.stop();
          }
        }, _callee45);
      })));
    });
    describe('onChange', function () {
      it('should update onChange callback', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee46() {
        var onChange1, onChange2, _render, driver, rerender;
        return _regenerator["default"].wrap(function _callee46$(_context46) {
          while (1) switch (_context46.prev = _context46.next) {
            case 0:
              onChange1 = vi.fn();
              onChange2 = vi.fn();
              _render = render(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                onChange: onChange1,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 536,
                  columnNumber: 45
                }
              })), driver = _render.driver, rerender = _render.rerender; // Expect to call onChange
              expect(onChange1).toHaveBeenCalledTimes(0);
              _context46.next = 6;
              return driver.inputDriver.enterText('yay');
            case 6:
              expect(onChange1).toHaveBeenCalledTimes(1);
              rerender(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                onChange: onChange2,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 543,
                  columnNumber: 18
                }
              }));

              // Expect to update and call the new onChange
              expect(onChange2).toHaveBeenCalledTimes(0);
              _context46.next = 11;
              return driver.inputDriver.enterText('yay-yay');
            case 11:
              expect(onChange2).toHaveBeenCalledTimes(1);
            case 12:
            case "end":
              return _context46.stop();
          }
        }, _callee46);
      })));
    });
    describe('Public methods', function () {
      describe('Search.focus', function () {
        it('should focus the input', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee48() {
          var ref, _render2, driver;
          return _regenerator["default"].wrap(function _callee48$(_context48) {
            while (1) switch (_context48.prev = _context48.next) {
              case 0:
                ref = /*#__PURE__*/_react["default"].createRef();
                _render2 = render(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                  ref: ref,
                  __self: _this,
                  __source: {
                    fileName: _jsxFileName,
                    lineNumber: 556,
                    columnNumber: 37
                  }
                })), driver = _render2.driver;
                _context48.next = 4;
                return (0, _unit.act)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee47() {
                  return _regenerator["default"].wrap(function _callee47$(_context47) {
                    while (1) switch (_context47.prev = _context47.next) {
                      case 0:
                        ref.current.focus();
                      case 1:
                      case "end":
                        return _context47.stop();
                    }
                  }, _callee47);
                })));
              case 4:
                _context48.t0 = expect;
                _context48.next = 7;
                return driver.inputDriver.isFocusedStyle();
              case 7:
                _context48.t1 = _context48.sent;
                (0, _context48.t0)(_context48.t1).toBe(true);
              case 9:
              case "end":
                return _context48.stop();
            }
          }, _callee48);
        })));
      });
      describe('Search.blur', function () {
        it('should blur the input', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee51() {
          var ref, _render3, driver;
          return _regenerator["default"].wrap(function _callee51$(_context51) {
            while (1) switch (_context51.prev = _context51.next) {
              case 0:
                ref = /*#__PURE__*/_react["default"].createRef();
                _render3 = render(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                  ref: ref,
                  __self: _this,
                  __source: {
                    fileName: _jsxFileName,
                    lineNumber: 569,
                    columnNumber: 37
                  }
                })), driver = _render3.driver;
                _context51.next = 4;
                return (0, _unit.act)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee49() {
                  return _regenerator["default"].wrap(function _callee49$(_context49) {
                    while (1) switch (_context49.prev = _context49.next) {
                      case 0:
                        ref.current.focus();
                      case 1:
                      case "end":
                        return _context49.stop();
                    }
                  }, _callee49);
                })));
              case 4:
                _context51.t0 = expect;
                _context51.next = 7;
                return driver.inputDriver.isFocusedStyle();
              case 7:
                _context51.t1 = _context51.sent;
                (0, _context51.t0)(_context51.t1).toBe(true);
                _context51.next = 11;
                return (0, _unit.act)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee50() {
                  return _regenerator["default"].wrap(function _callee50$(_context50) {
                    while (1) switch (_context50.prev = _context50.next) {
                      case 0:
                        ref.current.blur();
                      case 1:
                      case "end":
                        return _context50.stop();
                    }
                  }, _callee50);
                })));
              case 11:
                _context51.t2 = expect;
                _context51.next = 14;
                return driver.inputDriver.isFocusedStyle();
              case 14:
                _context51.t3 = _context51.sent;
                (0, _context51.t2)(_context51.t3).toBe(false);
              case 16:
              case "end":
                return _context51.stop();
            }
          }, _callee51);
        })));
      });
      describe('Search.clear', function () {
        it('should trigger onClear', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee53() {
          var onClear, ref;
          return _regenerator["default"].wrap(function _callee53$(_context53) {
            while (1) switch (_context53.prev = _context53.next) {
              case 0:
                onClear = vi.fn();
                ref = /*#__PURE__*/_react["default"].createRef();
                render(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                  ref: ref,
                  onClear: onClear,
                  __self: _this,
                  __source: {
                    fileName: _jsxFileName,
                    lineNumber: 585,
                    columnNumber: 18
                  }
                }));
                _context53.next = 5;
                return (0, _unit.act)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee52() {
                  return _regenerator["default"].wrap(function _callee52$(_context52) {
                    while (1) switch (_context52.prev = _context52.next) {
                      case 0:
                        ref.current.clear();
                      case 1:
                      case "end":
                        return _context52.stop();
                    }
                  }, _callee52);
                })));
              case 5:
                expect(onClear).toHaveBeenCalledTimes(1);
              case 6:
              case "end":
                return _context53.stop();
            }
          }, _callee53);
        })));
        it('should clear input', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee55() {
          var ref, _render4, driver;
          return _regenerator["default"].wrap(function _callee55$(_context55) {
            while (1) switch (_context55.prev = _context55.next) {
              case 0:
                ref = /*#__PURE__*/_react["default"].createRef();
                _render4 = render(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                  ref: ref,
                  defaultValue: "fox",
                  __self: _this,
                  __source: {
                    fileName: _jsxFileName,
                    lineNumber: 594,
                    columnNumber: 37
                  }
                })), driver = _render4.driver;
                _context55.t0 = expect;
                _context55.next = 5;
                return driver.inputDriver.getText();
              case 5:
                _context55.t1 = _context55.sent;
                (0, _context55.t0)(_context55.t1).toEqual('fox');
                _context55.next = 9;
                return (0, _unit.act)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee54() {
                  return _regenerator["default"].wrap(function _callee54$(_context54) {
                    while (1) switch (_context54.prev = _context54.next) {
                      case 0:
                        ref.current.clear();
                      case 1:
                      case "end":
                        return _context54.stop();
                    }
                  }, _callee54);
                })));
              case 9:
                _context55.t2 = expect;
                _context55.next = 12;
                return driver.inputDriver.getText();
              case 12:
                _context55.t3 = _context55.sent;
                (0, _context55.t2)(_context55.t3).toEqual('');
              case 14:
              case "end":
                return _context55.stop();
            }
          }, _callee55);
        })));
        it('clears input on clear button Space key press', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee56() {
          var driver;
          return _regenerator["default"].wrap(function _callee56$(_context56) {
            while (1) switch (_context56.prev = _context56.next) {
              case 0:
                driver = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                  defaultValue: "fox",
                  __self: _this,
                  __source: {
                    fileName: _jsxFileName,
                    lineNumber: 603,
                    columnNumber: 39
                  }
                }));
                _context56.t0 = expect;
                _context56.next = 4;
                return driver.inputDriver.getText();
              case 4:
                _context56.t1 = _context56.sent;
                (0, _context56.t0)(_context56.t1).toEqual('fox');
                _context56.next = 8;
                return driver.inputDriver.focus();
              case 8:
                _context56.next = 10;
                return _userEvent["default"].tab();
              case 10:
                _context56.next = 12;
                return _userEvent["default"].keyboard('[Space]');
              case 12:
                _context56.t2 = expect;
                _context56.next = 15;
                return driver.inputDriver.getText();
              case 15:
                _context56.t3 = _context56.sent;
                (0, _context56.t2)(_context56.t3).toEqual('');
              case 17:
              case "end":
                return _context56.stop();
            }
          }, _callee56);
        })));
        it('clears input on clear button Enter key press', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee57() {
          var driver;
          return _regenerator["default"].wrap(function _callee57$(_context57) {
            while (1) switch (_context57.prev = _context57.next) {
              case 0:
                driver = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                  defaultValue: "fox",
                  __self: _this,
                  __source: {
                    fileName: _jsxFileName,
                    lineNumber: 613,
                    columnNumber: 39
                  }
                }));
                _context57.t0 = expect;
                _context57.next = 4;
                return driver.inputDriver.getText();
              case 4:
                _context57.t1 = _context57.sent;
                (0, _context57.t0)(_context57.t1).toEqual('fox');
                _context57.next = 8;
                return driver.inputDriver.focus();
              case 8:
                _context57.next = 10;
                return _userEvent["default"].tab();
              case 10:
                _context57.next = 12;
                return _userEvent["default"].keyboard('[Enter]');
              case 12:
                _context57.t2 = expect;
                _context57.next = 15;
                return driver.inputDriver.getText();
              case 15:
                _context57.t3 = _context57.sent;
                (0, _context57.t2)(_context57.t3).toEqual('');
              case 17:
              case "end":
                return _context57.stop();
            }
          }, _callee57);
        })));
      });
    });
    describe('transition callbacks', function () {
      it('should call onExpandStart and onExpandEnd when expanding', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee58() {
        var onExpandTransitionStart, onExpandTransitionEnd, driver, contentElement;
        return _regenerator["default"].wrap(function _callee58$(_context58) {
          while (1) switch (_context58.prev = _context58.next) {
            case 0:
              onExpandTransitionStart = vi.fn();
              onExpandTransitionEnd = vi.fn();
              driver = createDriver(/*#__PURE__*/_react["default"].createElement(_Search["default"], {
                expandable: true,
                onExpandTransitionStart: onExpandTransitionStart,
                onExpandTransitionEnd: onExpandTransitionEnd,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 630,
                  columnNumber: 11
                }
              }));
              _context58.next = 5;
              return driver.getContentElement();
            case 5:
              contentElement = _context58.sent;
              _context58.next = 8;
              return driver.inputDriver.click();
            case 8:
              _react2.fireEvent.transitionStart(contentElement);
              expect(onExpandTransitionStart).toHaveBeenCalledTimes(1);
              expect(onExpandTransitionStart).toHaveBeenCalledWith(false);
              _react2.fireEvent.transitionEnd(contentElement);
              expect(onExpandTransitionEnd).toHaveBeenCalledTimes(1);
              expect(onExpandTransitionEnd).toHaveBeenCalledWith(false);
              onExpandTransitionStart.mockClear();
              onExpandTransitionEnd.mockClear();
              _context58.next = 18;
              return driver.inputDriver.blur();
            case 18:
              _react2.fireEvent.transitionStart(contentElement);
              expect(onExpandTransitionStart).toHaveBeenCalledTimes(1);
              expect(onExpandTransitionStart).toHaveBeenCalledWith(true);
              _react2.fireEvent.transitionEnd(contentElement);
              expect(onExpandTransitionEnd).toHaveBeenCalledTimes(1);
              expect(onExpandTransitionEnd).toHaveBeenCalledWith(true);
            case 24:
            case "end":
              return _context58.stop();
          }
        }, _callee58);
      })));
    });
  }
});