"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _react = _interopRequireDefault(require("react"));
var _Dropdown = _interopRequireDefault(require("../Dropdown"));
var _unit = require("../../utils/test-utils/unit");
var _DropdownUni = require("../Dropdown.uni.driver");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/Dropdown/test/Dropdown.spec.jsx";
describe('Dropdown', function () {
  describe('[async]', function () {
    runTests((0, _unit.createRendererWithUniDriver)(_DropdownUni.dropdownUniDriverFactory));
  });
  function runTests(render) {
    var _this = this;
    afterEach(function () {
      return (0, _unit.cleanup)();
    });
    var createDriver = function createDriver(jsx) {
      return render(jsx).driver;
    };
    var getOptions = function getOptions() {
      return [{
        id: 0,
        value: 'Option 1'
      }, {
        id: 1,
        value: 'Option 2'
      }, {
        id: 2,
        value: 'Option 3',
        disabled: true
      }, {
        id: 3,
        value: 'Option 4'
      }, {
        id: 'divider1',
        value: '-'
      }, {
        id: 'element1',
        value: /*#__PURE__*/_react["default"].createElement("span", {
          style: {
            color: 'brown'
          },
          __self: _this,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 29,
            columnNumber: 16
          }
        }, "Option 4")
      }];
    };
    describe('Dropdown', function () {
      it('should open on enter key', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
        var _createDriver, dropdownLayoutDriver, inputDriver;
        return _regenerator["default"].wrap(function _callee$(_context) {
          while (1) switch (_context.prev = _context.next) {
            case 0:
              _createDriver = createDriver(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                options: getOptions(),
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 36,
                  columnNumber: 11
                }
              })), dropdownLayoutDriver = _createDriver.dropdownLayoutDriver, inputDriver = _createDriver.inputDriver;
              _context.next = 3;
              return inputDriver.pressKey('Enter');
            case 3:
              _context.t0 = expect;
              _context.next = 6;
              return dropdownLayoutDriver.isShown();
            case 6:
              _context.t1 = _context.sent;
              (0, _context.t0)(_context.t1).toBe(true);
            case 8:
            case "end":
              return _context.stop();
          }
        }, _callee);
      })));
      it('should open on space key', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() {
        var _createDriver2, dropdownLayoutDriver, inputDriver;
        return _regenerator["default"].wrap(function _callee2$(_context2) {
          while (1) switch (_context2.prev = _context2.next) {
            case 0:
              _createDriver2 = createDriver(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                options: getOptions(),
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 44,
                  columnNumber: 11
                }
              })), dropdownLayoutDriver = _createDriver2.dropdownLayoutDriver, inputDriver = _createDriver2.inputDriver;
              _context2.next = 3;
              return inputDriver.pressKey(' ');
            case 3:
              _context2.t0 = expect;
              _context2.next = 6;
              return dropdownLayoutDriver.isShown();
            case 6:
              _context2.t1 = _context2.sent;
              (0, _context2.t0)(_context2.t1).toBe(true);
            case 8:
            case "end":
              return _context2.stop();
          }
        }, _callee2);
      })));
      it('should open on arrow down key', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3() {
        var _createDriver3, dropdownLayoutDriver, inputDriver;
        return _regenerator["default"].wrap(function _callee3$(_context3) {
          while (1) switch (_context3.prev = _context3.next) {
            case 0:
              _createDriver3 = createDriver(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                options: getOptions(),
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 52,
                  columnNumber: 11
                }
              })), dropdownLayoutDriver = _createDriver3.dropdownLayoutDriver, inputDriver = _createDriver3.inputDriver;
              _context3.next = 3;
              return inputDriver.pressKey('ArrowDown');
            case 3:
              _context3.t0 = expect;
              _context3.next = 6;
              return dropdownLayoutDriver.isShown();
            case 6:
              _context3.t1 = _context3.sent;
              (0, _context3.t0)(_context3.t1).toBe(true);
            case 8:
            case "end":
              return _context3.stop();
          }
        }, _callee3);
      })));
      it('should open on arrow up key', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4() {
        var _createDriver4, dropdownLayoutDriver, inputDriver;
        return _regenerator["default"].wrap(function _callee4$(_context4) {
          while (1) switch (_context4.prev = _context4.next) {
            case 0:
              _createDriver4 = createDriver(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                options: getOptions(),
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 60,
                  columnNumber: 11
                }
              })), dropdownLayoutDriver = _createDriver4.dropdownLayoutDriver, inputDriver = _createDriver4.inputDriver;
              _context4.next = 3;
              return inputDriver.pressKey('ArrowUp');
            case 3:
              _context4.t0 = expect;
              _context4.next = 6;
              return dropdownLayoutDriver.isShown();
            case 6:
              _context4.t1 = _context4.sent;
              (0, _context4.t0)(_context4.t1).toBe(true);
            case 8:
            case "end":
              return _context4.stop();
          }
        }, _callee4);
      })));
    });
    describe('Uncontrolled SelectedId', function () {
      it('should select item with selectedId on init state', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5() {
        var _createDriver5, inputDriver, dropdownLayoutDriver;
        return _regenerator["default"].wrap(function _callee5$(_context5) {
          while (1) switch (_context5.prev = _context5.next) {
            case 0:
              _createDriver5 = createDriver(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                options: getOptions(),
                initialSelectedId: 0,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 70,
                  columnNumber: 11
                }
              })), inputDriver = _createDriver5.inputDriver, dropdownLayoutDriver = _createDriver5.dropdownLayoutDriver;
              _context5.t0 = expect;
              _context5.next = 4;
              return dropdownLayoutDriver.isOptionSelected(0);
            case 4:
              _context5.t1 = _context5.sent;
              (0, _context5.t0)(_context5.t1).toBe(true);
              _context5.t2 = expect;
              _context5.next = 9;
              return inputDriver.getValue();
            case 9:
              _context5.t3 = _context5.sent;
              (0, _context5.t2)(_context5.t3).toBe('Option 1');
            case 11:
            case "end":
              return _context5.stop();
          }
        }, _callee5);
      })));
      it('should select an item when clicked', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6() {
        var _createDriver6, driver, dropdownLayoutDriver;
        return _regenerator["default"].wrap(function _callee6$(_context6) {
          while (1) switch (_context6.prev = _context6.next) {
            case 0:
              _createDriver6 = createDriver(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                options: getOptions(),
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 79,
                  columnNumber: 11
                }
              })), driver = _createDriver6.driver, dropdownLayoutDriver = _createDriver6.dropdownLayoutDriver;
              _context6.next = 3;
              return driver.focus();
            case 3:
              _context6.next = 5;
              return dropdownLayoutDriver.clickAtOption(0);
            case 5:
              _context6.t0 = expect;
              _context6.next = 8;
              return dropdownLayoutDriver.isOptionSelected(0);
            case 8:
              _context6.t1 = _context6.sent;
              (0, _context6.t0)(_context6.t1).toBe(true);
            case 10:
            case "end":
              return _context6.stop();
          }
        }, _callee6);
      })));
      it('should enter the selected option text when selected', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7() {
        var _createDriver7, driver, inputDriver, dropdownLayoutDriver;
        return _regenerator["default"].wrap(function _callee7$(_context7) {
          while (1) switch (_context7.prev = _context7.next) {
            case 0:
              _createDriver7 = createDriver(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                options: getOptions(),
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 88,
                  columnNumber: 11
                }
              })), driver = _createDriver7.driver, inputDriver = _createDriver7.inputDriver, dropdownLayoutDriver = _createDriver7.dropdownLayoutDriver;
              _context7.next = 3;
              return driver.focus();
            case 3:
              _context7.next = 5;
              return dropdownLayoutDriver.clickAtOption(0);
            case 5:
              _context7.t0 = expect;
              _context7.next = 8;
              return inputDriver.getValue();
            case 8:
              _context7.t1 = _context7.sent;
              (0, _context7.t0)(_context7.t1).toBe('Option 1');
            case 10:
            case "end":
              return _context7.stop();
          }
        }, _callee7);
      })));
      it('should close when clicking on input (header)', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee1() {
        var _createDriver8, dropdownLayoutDriver, inputDriver;
        return _regenerator["default"].wrap(function _callee1$(_context1) {
          while (1) switch (_context1.prev = _context1.next) {
            case 0:
              vi.useFakeTimers();
              _createDriver8 = createDriver(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                options: getOptions(),
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 99,
                  columnNumber: 11
                }
              })), dropdownLayoutDriver = _createDriver8.dropdownLayoutDriver, inputDriver = _createDriver8.inputDriver;
              _context1.next = 4;
              return (0, _unit.act)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee8() {
                return _regenerator["default"].wrap(function _callee8$(_context8) {
                  while (1) switch (_context8.prev = _context8.next) {
                    case 0:
                      _context8.next = 2;
                      return inputDriver.click();
                    case 2:
                    case "end":
                      return _context8.stop();
                  }
                }, _callee8);
              })));
            case 4:
              _context1.t0 = expect;
              _context1.next = 7;
              return dropdownLayoutDriver.isShown();
            case 7:
              _context1.t1 = _context1.sent;
              (0, _context1.t0)(_context1.t1).toBe(true);
              _context1.next = 11;
              return (0, _unit.act)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee9() {
                return _regenerator["default"].wrap(function _callee9$(_context9) {
                  while (1) switch (_context9.prev = _context9.next) {
                    case 0:
                      vi.advanceTimersByTime(201);
                    case 1:
                    case "end":
                      return _context9.stop();
                  }
                }, _callee9);
              })));
            case 11:
              _context1.next = 13;
              return inputDriver.click();
            case 13:
              _context1.next = 15;
              return (0, _unit.waitFor)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee0() {
                return _regenerator["default"].wrap(function _callee0$(_context0) {
                  while (1) switch (_context0.prev = _context0.next) {
                    case 0:
                      _context0.t0 = expect;
                      _context0.next = 3;
                      return dropdownLayoutDriver.isShown();
                    case 3:
                      _context0.t1 = _context0.sent;
                      (0, _context0.t0)(_context0.t1).toBe(false);
                    case 5:
                    case "end":
                      return _context0.stop();
                  }
                }, _callee0);
              })));
            case 15:
              vi.useRealTimers();
            case 16:
            case "end":
              return _context1.stop();
          }
        }, _callee1);
      })));
      it('should not be editable ', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee10() {
        var _createDriver9, driver;
        return _regenerator["default"].wrap(function _callee10$(_context10) {
          while (1) switch (_context10.prev = _context10.next) {
            case 0:
              _createDriver9 = createDriver(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                options: getOptions(),
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 122,
                  columnNumber: 41
                }
              })), driver = _createDriver9.driver;
              _context10.t0 = expect;
              _context10.next = 4;
              return driver.isEditable();
            case 4:
              _context10.t1 = _context10.sent;
              (0, _context10.t0)(_context10.t1).toBe(false);
            case 6:
            case "end":
              return _context10.stop();
          }
        }, _callee10);
      })));
      it('should have no selection when initialSelectedId is null', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee11() {
        var _render, _driver, dropdownLayoutDriver, inputDriver;
        return _regenerator["default"].wrap(function _callee11$(_context11) {
          while (1) switch (_context11.prev = _context11.next) {
            case 0:
              _render = render(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                options: [{
                  id: 0,
                  value: 'Option 1'
                }],
                initialSelectedId: null,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 128,
                  columnNumber: 11
                }
              })), _driver = _render.driver;
              dropdownLayoutDriver = _driver.dropdownLayoutDriver, inputDriver = _driver.inputDriver;
              _context11.t0 = expect;
              _context11.next = 5;
              return dropdownLayoutDriver.isOptionSelected(0);
            case 5:
              _context11.t1 = _context11.sent;
              (0, _context11.t0)(_context11.t1).toBe(false);
              _context11.t2 = expect;
              _context11.next = 10;
              return inputDriver.getValue();
            case 10:
              _context11.t3 = _context11.sent;
              (0, _context11.t2)(_context11.t3).toBe('');
            case 12:
            case "end":
              return _context11.stop();
          }
        }, _callee11);
      })));
      describe('initiallySelected', function () {
        it('should keep selectedId and value when initialSelectedId changed', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee12() {
          var _render2, _driver, rerender, dropdownLayoutDriver;
          return _regenerator["default"].wrap(function _callee12$(_context12) {
            while (1) switch (_context12.prev = _context12.next) {
              case 0:
                _render2 = render(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                  options: getOptions(),
                  initialSelectedId: 0,
                  __self: _this,
                  __source: {
                    fileName: _jsxFileName,
                    lineNumber: 143,
                    columnNumber: 13
                  }
                })), _driver = _render2.driver, rerender = _render2.rerender;
                dropdownLayoutDriver = _driver.dropdownLayoutDriver;
                _context12.t0 = expect;
                _context12.next = 5;
                return dropdownLayoutDriver.isOptionSelected(0);
              case 5:
                _context12.t1 = _context12.sent;
                (0, _context12.t0)(_context12.t1).toBe(true);
                rerender(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                  options: getOptions(),
                  initialSelectedId: 1,
                  __self: _this,
                  __source: {
                    fileName: _jsxFileName,
                    lineNumber: 147,
                    columnNumber: 20
                  }
                }));
                _context12.t2 = expect;
                _context12.next = 11;
                return dropdownLayoutDriver.isOptionSelected(0);
              case 11:
                _context12.t3 = _context12.sent;
                (0, _context12.t2)(_context12.t3).toBe(true);
              case 13:
              case "end":
                return _context12.stop();
            }
          }, _callee12);
        })));
      });
      it("should update selectedId when options change and id does not exist anymore", /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee13() {
        var _render3, _driver, rerender, inputDriver, dropdownLayoutDriver, option, options, isAnyOptionSelected;
        return _regenerator["default"].wrap(function _callee13$(_context13) {
          while (1) switch (_context13.prev = _context13.next) {
            case 0:
              _render3 = render(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                options: [{
                  id: 0,
                  value: 'Option 1'
                }, {
                  id: 1,
                  value: 'Option 2'
                }],
                initialSelectedId: 0,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 154,
                  columnNumber: 11
                }
              })), _driver = _render3.driver, rerender = _render3.rerender;
              inputDriver = _driver.inputDriver, dropdownLayoutDriver = _driver.dropdownLayoutDriver;
              _context13.next = 4;
              return dropdownLayoutDriver.optionById(0);
            case 4:
              option = _context13.sent;
              _context13.t0 = expect;
              _context13.next = 8;
              return option.isSelected();
            case 8:
              _context13.t1 = _context13.sent;
              (0, _context13.t0)(_context13.t1).toBe(true);
              _context13.t2 = expect;
              _context13.next = 13;
              return inputDriver.getValue();
            case 13:
              _context13.t3 = _context13.sent;
              (0, _context13.t2)(_context13.t3).toBe('Option 1');
              rerender(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                options: [{
                  id: 1,
                  value: 'Option 2'
                }],
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 167,
                  columnNumber: 18
                }
              }));
              _context13.next = 18;
              return dropdownLayoutDriver.options();
            case 18:
              options = _context13.sent;
              _context13.next = 21;
              return Promise.all(options.map(function (option) {
                return option.isSelected();
              }));
            case 21:
              isAnyOptionSelected = _context13.sent.some(function (val) {
                return val;
              });
              expect(isAnyOptionSelected).toBe(false);
              _context13.t4 = expect;
              _context13.next = 26;
              return inputDriver.getValue();
            case 26:
              _context13.t5 = _context13.sent;
              (0, _context13.t4)(_context13.t5).toBe('');
            case 28:
            case "end":
              return _context13.stop();
          }
        }, _callee13);
      })));
      it('should select item with selectedId on async init', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee14() {
        var _render4, _driver, rerender, inputDriver, dropdownLayoutDriver, options, isAnyOptionSelected, option;
        return _regenerator["default"].wrap(function _callee14$(_context14) {
          while (1) switch (_context14.prev = _context14.next) {
            case 0:
              _render4 = render(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                options: [],
                selectedId: 0,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 180,
                  columnNumber: 11
                }
              })), _driver = _render4.driver, rerender = _render4.rerender;
              inputDriver = _driver.inputDriver, dropdownLayoutDriver = _driver.dropdownLayoutDriver;
              _context14.next = 4;
              return dropdownLayoutDriver.options();
            case 4:
              options = _context14.sent;
              _context14.next = 7;
              return Promise.all(options.map(function (option) {
                return option.isSelected();
              }));
            case 7:
              isAnyOptionSelected = _context14.sent.some(function (val) {
                return val;
              });
              expect(isAnyOptionSelected).toBe(false);
              _context14.t0 = expect;
              _context14.next = 12;
              return inputDriver.getValue();
            case 12:
              _context14.t1 = _context14.sent;
              (0, _context14.t0)(_context14.t1).toBe('');
              rerender(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                options: [{
                  id: 0,
                  value: 'Option 1'
                }, {
                  id: 1,
                  value: 'Option 2'
                }],
                selectedId: 0,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 193,
                  columnNumber: 11
                }
              }));
              _context14.next = 17;
              return dropdownLayoutDriver.optionById(0);
            case 17:
              option = _context14.sent;
              _context14.t2 = expect;
              _context14.next = 21;
              return option.isSelected();
            case 21:
              _context14.t3 = _context14.sent;
              (0, _context14.t2)(_context14.t3).toBe(true);
              _context14.t4 = expect;
              _context14.next = 26;
              return inputDriver.getValue();
            case 26:
              _context14.t5 = _context14.sent;
              (0, _context14.t4)(_context14.t5).toBe('Option 1');
            case 28:
            case "end":
              return _context14.stop();
          }
        }, _callee14);
      })));
    });
    describe('Controlled SelectedId', function () {
      it('should keep current selection and value when option clicked', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee15() {
        var _createDriver0, driver, dropdownLayoutDriver, inputDriver;
        return _regenerator["default"].wrap(function _callee15$(_context15) {
          while (1) switch (_context15.prev = _context15.next) {
            case 0:
              _createDriver0 = createDriver(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                options: getOptions(),
                selectedId: 0,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 211,
                  columnNumber: 11
                }
              })), driver = _createDriver0.driver, dropdownLayoutDriver = _createDriver0.dropdownLayoutDriver, inputDriver = _createDriver0.inputDriver;
              _context15.next = 3;
              return driver.focus();
            case 3:
              _context15.next = 5;
              return dropdownLayoutDriver.clickAtOption(1);
            case 5:
              _context15.t0 = expect;
              _context15.next = 8;
              return dropdownLayoutDriver.isOptionSelected(0);
            case 8:
              _context15.t1 = _context15.sent;
              (0, _context15.t0)(_context15.t1).toBe(true);
              _context15.t2 = expect;
              _context15.next = 13;
              return inputDriver.getValue();
            case 13:
              _context15.t3 = _context15.sent;
              (0, _context15.t2)(_context15.t3).toBe('Option 1');
            case 15:
            case "end":
              return _context15.stop();
          }
        }, _callee15);
      })));
      it('should have no selection if selectedId does not exist', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee16() {
        var _createDriver1, dropdownLayoutDriver, option;
        return _regenerator["default"].wrap(function _callee16$(_context16) {
          while (1) switch (_context16.prev = _context16.next) {
            case 0:
              _createDriver1 = createDriver(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                options: [{
                  id: 0,
                  value: 'Option 1'
                }],
                selectedId: 99,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 224,
                  columnNumber: 11
                }
              })), dropdownLayoutDriver = _createDriver1.dropdownLayoutDriver;
              _context16.next = 3;
              return dropdownLayoutDriver.optionById(0);
            case 3:
              option = _context16.sent;
              _context16.t0 = expect;
              _context16.next = 7;
              return option.isSelected();
            case 7:
              _context16.t1 = _context16.sent;
              (0, _context16.t0)(_context16.t1).toBe(false);
            case 9:
            case "end":
              return _context16.stop();
          }
        }, _callee16);
      })));
      it('should update selection and value when selectedId changes', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee17() {
        var _render5, _driver, rerender, dropdownLayoutDriver, inputDriver;
        return _regenerator["default"].wrap(function _callee17$(_context17) {
          while (1) switch (_context17.prev = _context17.next) {
            case 0:
              _render5 = render(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                options: getOptions(),
                selectedId: 0,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 232,
                  columnNumber: 11
                }
              })), _driver = _render5.driver, rerender = _render5.rerender;
              dropdownLayoutDriver = _driver.dropdownLayoutDriver, inputDriver = _driver.inputDriver;
              _context17.t0 = expect;
              _context17.next = 5;
              return dropdownLayoutDriver.isOptionSelected(0);
            case 5:
              _context17.t1 = _context17.sent;
              (0, _context17.t0)(_context17.t1).toBe(true);
              _context17.t2 = expect;
              _context17.next = 10;
              return inputDriver.getValue();
            case 10:
              _context17.t3 = _context17.sent;
              (0, _context17.t2)(_context17.t3).toBe('Option 1');
              rerender(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                options: getOptions(),
                selectedId: 1,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 239,
                  columnNumber: 18
                }
              }));
              _context17.t4 = expect;
              _context17.next = 16;
              return dropdownLayoutDriver.isOptionSelected(1);
            case 16:
              _context17.t5 = _context17.sent;
              (0, _context17.t4)(_context17.t5).toBe(true);
              _context17.t6 = expect;
              _context17.next = 21;
              return inputDriver.getValue();
            case 21:
              _context17.t7 = _context17.sent;
              (0, _context17.t6)(_context17.t7).toBe('Option 2');
            case 23:
            case "end":
              return _context17.stop();
          }
        }, _callee17);
      })));
      it('should have no selection when selectedId is null', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee18() {
        var _render6, _driver, dropdownLayoutDriver, inputDriver;
        return _regenerator["default"].wrap(function _callee18$(_context18) {
          while (1) switch (_context18.prev = _context18.next) {
            case 0:
              _render6 = render(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                options: [{
                  id: 0,
                  value: 'Option 1'
                }],
                selectedId: null,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 247,
                  columnNumber: 11
                }
              })), _driver = _render6.driver;
              dropdownLayoutDriver = _driver.dropdownLayoutDriver, inputDriver = _driver.inputDriver;
              _context18.t0 = expect;
              _context18.next = 5;
              return dropdownLayoutDriver.isOptionSelected(0);
            case 5:
              _context18.t1 = _context18.sent;
              (0, _context18.t0)(_context18.t1).toBe(false);
              _context18.t2 = expect;
              _context18.next = 10;
              return inputDriver.getValue();
            case 10:
              _context18.t3 = _context18.sent;
              (0, _context18.t2)(_context18.t3).toBe('');
            case 12:
            case "end":
              return _context18.stop();
          }
        }, _callee18);
      })));
    });
    describe('Rerender', function () {
      it('should clear selection when selectedId is updated to null', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee19() {
        var _render7, _driver, rerender, dropdownLayoutDriver, inputDriver;
        return _regenerator["default"].wrap(function _callee19$(_context19) {
          while (1) switch (_context19.prev = _context19.next) {
            case 0:
              _render7 = render(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                options: getOptions(),
                selectedId: 0,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 263,
                  columnNumber: 11
                }
              })), _driver = _render7.driver, rerender = _render7.rerender;
              dropdownLayoutDriver = _driver.dropdownLayoutDriver, inputDriver = _driver.inputDriver;
              _context19.t0 = expect;
              _context19.next = 5;
              return dropdownLayoutDriver.isOptionSelected(0);
            case 5:
              _context19.t1 = _context19.sent;
              (0, _context19.t0)(_context19.t1).toBe(true);
              _context19.t2 = expect;
              _context19.next = 10;
              return inputDriver.getValue();
            case 10:
              _context19.t3 = _context19.sent;
              (0, _context19.t2)(_context19.t3).toBe('Option 1');
              rerender(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                options: getOptions(),
                selectedId: null,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 270,
                  columnNumber: 18
                }
              }));
              _context19.t4 = expect;
              _context19.next = 16;
              return dropdownLayoutDriver.isOptionSelected(0);
            case 16:
              _context19.t5 = _context19.sent;
              (0, _context19.t4)(_context19.t5).toBe(false);
              _context19.t6 = expect;
              _context19.next = 21;
              return inputDriver.getValue();
            case 21:
              _context19.t7 = _context19.sent;
              (0, _context19.t6)(_context19.t7).toBe('');
            case 23:
            case "end":
              return _context19.stop();
          }
        }, _callee19);
      })));
    });
    describe('Properties', function () {
      it('should not open dropdown on input click [when] readOnly prop is set to true', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee20() {
        var _createDriver10, dropdownLayoutDriver, inputDriver;
        return _regenerator["default"].wrap(function _callee20$(_context20) {
          while (1) switch (_context20.prev = _context20.next) {
            case 0:
              _createDriver10 = createDriver(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                readOnly: true,
                options: getOptions(),
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 280,
                  columnNumber: 11
                }
              })), dropdownLayoutDriver = _createDriver10.dropdownLayoutDriver, inputDriver = _createDriver10.inputDriver;
              _context20.next = 3;
              return inputDriver.click();
            case 3:
              _context20.t0 = expect;
              _context20.next = 6;
              return dropdownLayoutDriver.isShown();
            case 6:
              _context20.t1 = _context20.sent;
              (0, _context20.t0)(_context20.t1).toBe(false);
            case 8:
            case "end":
              return _context20.stop();
          }
        }, _callee20);
      })));
      it('should not open dropdown on input click [when] disabled prop is set to true', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee21() {
        var _createDriver11, dropdownLayoutDriver, inputDriver;
        return _regenerator["default"].wrap(function _callee21$(_context21) {
          while (1) switch (_context21.prev = _context21.next) {
            case 0:
              _createDriver11 = createDriver(/*#__PURE__*/_react["default"].createElement(_Dropdown["default"], {
                disabled: true,
                options: getOptions(),
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 288,
                  columnNumber: 11
                }
              })), dropdownLayoutDriver = _createDriver11.dropdownLayoutDriver, inputDriver = _createDriver11.inputDriver;
              _context21.next = 3;
              return inputDriver.click();
            case 3:
              _context21.t0 = expect;
              _context21.next = 6;
              return dropdownLayoutDriver.isShown();
            case 6:
              _context21.t1 = _context21.sent;
              (0, _context21.t0)(_context21.t1).toBe(false);
            case 8:
            case "end":
              return _context21.stop();
          }
        }, _callee21);
      })));
    });
  }
});