"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 _react = _interopRequireDefault(require("react"));
var _RichTextInputArea = _interopRequireDefault(require("../RichTextInputArea"));
var _RichTextInputAreaPrivateUni = _interopRequireDefault(require("../RichTextInputArea.private.uni.driver"));
var _react2 = require("../../utils/test-utils/react");
var _polyfills = require("../../polyfills");
var _unit = require("../../utils/test-utils/unit");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/RichTextInputArea/test/RichTextInputArea.spec.jsx",
  _this = void 0;
describe('RichTextInputArea', function () {
  afterEach(function () {
    (0, _unit.cleanup)();
  });
  var render = (0, _react2.createRendererWithUniDriver)(_RichTextInputAreaPrivateUni["default"]);

  // Keeps the parsed HTML value on prop change
  var currentValue;
  beforeAll(function () {
    _polyfills.scrollBehaviorPolyfill.install();
  });
  afterAll(function () {
    _polyfills.scrollBehaviorPolyfill.uninstall();
  });
  describe('Editor', function () {
    it('should render the text when `initialValue` prop is plain text', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
      var text, _render, driver;
      return _regenerator["default"].wrap(function _callee$(_context) {
        while (1) switch (_context.prev = _context.next) {
          case 0:
            text = 'Some text';
            _render = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
              initialValue: text,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 35,
                columnNumber: 33
              }
            })), driver = _render.driver;
            _context.t0 = expect;
            _context.next = 5;
            return driver.exists();
          case 5:
            _context.t1 = _context.sent;
            (0, _context.t0)(_context.t1).toBe(true);
            _context.t2 = expect;
            _context.next = 10;
            return driver.getContent();
          case 10:
            _context.t3 = _context.sent;
            (0, _context.t2)(_context.t3).toBe(text);
          case 12:
          case "end":
            return _context.stop();
        }
      }, _callee);
    })));
    it('should render the text when `value` prop contains HTML elements', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() {
      var texts, expectedText, _render2, driver;
      return _regenerator["default"].wrap(function _callee2$(_context2) {
        while (1) switch (_context2.prev = _context2.next) {
          case 0:
            texts = ['Some', 'text'];
            expectedText = texts.join(' ');
            _render2 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
              initialValue: "<p>".concat(texts[0], " <strong>").concat(texts[1], "</strong></p>"),
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 45,
                columnNumber: 9
              }
            })), driver = _render2.driver;
            _context2.t0 = expect;
            _context2.next = 6;
            return driver.exists();
          case 6:
            _context2.t1 = _context2.sent;
            (0, _context2.t0)(_context2.t1).toBe(true);
            _context2.t2 = expect;
            _context2.next = 11;
            return driver.getContent();
          case 11:
            _context2.t3 = _context2.sent;
            (0, _context2.t2)(_context2.t3).toBe(expectedText);
          case 13:
          case "end":
            return _context2.stop();
        }
      }, _callee2);
    })));
    it('should keep newlines when `initialValue` prop contains empty HTML elements', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3() {
      var _render3, driver, content;
      return _regenerator["default"].wrap(function _callee3$(_context3) {
        while (1) switch (_context3.prev = _context3.next) {
          case 0:
            _render3 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
              initialValue: "<p>hello<br/></br><p></p>world</p>",
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 56,
                columnNumber: 9
              }
            })), driver = _render3.driver;
            _context3.next = 3;
            return driver.getContent();
          case 3:
            content = _context3.sent;
            expect(content).toEqual('hello\n\n\nworld');
          case 5:
          case "end":
            return _context3.stop();
        }
      }, _callee3);
    })));
    describe('onChange', function () {
      it('should invoke with correct params after typing text', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4() {
        var callback, text, expectedHtmlValue, _render4, driver;
        return _regenerator["default"].wrap(function _callee4$(_context4) {
          while (1) switch (_context4.prev = _context4.next) {
            case 0:
              callback = vi.fn();
              text = 'Some text';
              expectedHtmlValue = "<p>".concat(text, "</p>");
              _render4 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
                onChange: callback,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 68,
                  columnNumber: 35
                }
              })), driver = _render4.driver;
              _context4.next = 6;
              return driver.enterText(text);
            case 6:
              expect(callback).toHaveBeenCalledWith(expectedHtmlValue, {
                plainText: text
              });
            case 7:
            case "end":
              return _context4.stop();
          }
        }, _callee4);
      })));
      it('should not invoke with extra line-break', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5() {
        var callback, text, expectedHtmlValue, _render5, driver;
        return _regenerator["default"].wrap(function _callee5$(_context5) {
          while (1) switch (_context5.prev = _context5.next) {
            case 0:
              callback = vi.fn();
              text = '\n';
              expectedHtmlValue = "<p>".concat(text, "</p>");
              _render5 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
                onChange: callback,
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 81,
                  columnNumber: 35
                }
              })), driver = _render5.driver;
              _context5.next = 6;
              return driver.enterText(text);
            case 6:
              expect(callback).toHaveBeenCalledWith(expectedHtmlValue, {
                plainText: text
              });
            case 7:
            case "end":
              return _context5.stop();
          }
        }, _callee5);
      })));
    });
    it('should render a placeholder', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6() {
      var placeholderText, _render6, driver;
      return _regenerator["default"].wrap(function _callee6$(_context6) {
        while (1) switch (_context6.prev = _context6.next) {
          case 0:
            placeholderText = 'Placeholder';
            _render6 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
              placeholder: placeholderText,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 94,
                columnNumber: 9
              }
            })), driver = _render6.driver;
            _context6.t0 = expect;
            _context6.next = 5;
            return driver.getContent();
          case 5:
            _context6.t1 = _context6.sent;
            (0, _context6.t0)(_context6.t1).toBe('');
            _context6.t2 = expect;
            _context6.next = 10;
            return driver.getPlaceholder();
          case 10:
            _context6.t3 = _context6.sent;
            (0, _context6.t2)(_context6.t3).toBe(placeholderText);
          case 12:
          case "end":
            return _context6.stop();
        }
      }, _callee6);
    })));
    it('should not render the placeholder after inserting text', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7() {
      var expectedText, _render7, driver;
      return _regenerator["default"].wrap(function _callee7$(_context7) {
        while (1) switch (_context7.prev = _context7.next) {
          case 0:
            expectedText = 'Some text';
            _render7 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
              placeholder: "Placeholder",
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 104,
                columnNumber: 9
              }
            })), driver = _render7.driver;
            _context7.next = 4;
            return driver.enterText(expectedText);
          case 4:
            _context7.t0 = expect;
            _context7.next = 7;
            return driver.getContent();
          case 7:
            _context7.t1 = _context7.sent;
            (0, _context7.t0)(_context7.t1).toBe(expectedText);
            _context7.t2 = expect;
            _context7.next = 12;
            return driver.hasPlaceholder();
          case 12:
            _context7.t3 = _context7.sent;
            (0, _context7.t2)(_context7.t3).toBe(false);
          case 14:
          case "end":
            return _context7.stop();
        }
      }, _callee7);
    })));
  });
  it('should render as disabled', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee8() {
    var _render8, driver;
    return _regenerator["default"].wrap(function _callee8$(_context8) {
      while (1) switch (_context8.prev = _context8.next) {
        case 0:
          _render8 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
            disabled: true,
            __self: _this,
            __source: {
              fileName: _jsxFileName,
              lineNumber: 115,
              columnNumber: 31
            }
          })), driver = _render8.driver;
          _context8.t0 = expect;
          _context8.next = 4;
          return driver.isDisabled();
        case 4:
          _context8.t1 = _context8.sent;
          (0, _context8.t0)(_context8.t1).toBe(true);
        case 6:
        case "end":
          return _context8.stop();
      }
    }, _callee8);
  })));
  describe('status attribute', function () {
    it('should have no status', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee9() {
      var render, _render9, driver;
      return _regenerator["default"].wrap(function _callee9$(_context9) {
        while (1) switch (_context9.prev = _context9.next) {
          case 0:
            render = (0, _react2.createRendererWithUniDriver)(_RichTextInputAreaPrivateUni["default"]);
            _render9 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 125,
                columnNumber: 33
              }
            })), driver = _render9.driver;
            _context9.t0 = expect;
            _context9.next = 5;
            return driver.hasStatus('error');
          case 5:
            _context9.t1 = _context9.sent;
            (0, _context9.t0)(_context9.t1).toBe(false);
          case 7:
          case "end":
            return _context9.stop();
        }
      }, _callee9);
    })));
    it('should not render the status indicator when disabled', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee0() {
      var _render0, driver;
      return _regenerator["default"].wrap(function _callee0$(_context0) {
        while (1) switch (_context0.prev = _context0.next) {
          case 0:
            _render0 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
              disabled: true,
              status: "error",
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 131,
                columnNumber: 33
              }
            })), driver = _render0.driver;
            _context0.t0 = expect;
            _context0.next = 4;
            return driver.hasStatus();
          case 4:
            _context0.t1 = _context0.sent;
            (0, _context0.t0)(_context0.t1).toBe(false);
          case 6:
          case "end":
            return _context0.stop();
        }
      }, _callee0);
    })));
    it.each([{
      status: 'error'
    }, {
      status: 'warning'
    }, {
      status: 'loading'
    }])('should display status when %p', /*#__PURE__*/function () {
      var _ref1 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee1(test) {
        var render, _render1, driver;
        return _regenerator["default"].wrap(function _callee1$(_context1) {
          while (1) switch (_context1.prev = _context1.next) {
            case 0:
              render = (0, _react2.createRendererWithUniDriver)(_RichTextInputAreaPrivateUni["default"]);
              _render1 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], (0, _extends2["default"])({}, test, {
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 144,
                  columnNumber: 33
                }
              }))), driver = _render1.driver;
              _context1.t0 = expect;
              _context1.next = 5;
              return driver.hasStatus(test.status);
            case 5:
              _context1.t1 = _context1.sent;
              (0, _context1.t0)(_context1.t1).toBe(true);
              _context1.t2 = expect;
              _context1.next = 10;
              return driver.getStatusMessage();
            case 10:
              _context1.t3 = _context1.sent;
              (0, _context1.t2)(_context1.t3).toBeNull();
            case 12:
            case "end":
              return _context1.stop();
          }
        }, _callee1);
      }));
      return function (_x) {
        return _ref1.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 _ref10 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee10(test) {
        var render, _render10, driver;
        return _regenerator["default"].wrap(function _callee10$(_context10) {
          while (1) switch (_context10.prev = _context10.next) {
            case 0:
              render = (0, _react2.createRendererWithUniDriver)(_RichTextInputAreaPrivateUni["default"]);
              _render10 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], (0, _extends2["default"])({}, test, {
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 158,
                  columnNumber: 33
                }
              }))), driver = _render10.driver;
              _context10.t0 = expect;
              _context10.next = 5;
              return driver.hasStatus(test.status);
            case 5:
              _context10.t1 = _context10.sent;
              (0, _context10.t0)(_context10.t1).toBe(true);
              _context10.t2 = expect;
              _context10.next = 10;
              return driver.getStatusMessage();
            case 10:
              _context10.t3 = _context10.sent;
              (0, _context10.t2)(_context10.t3).toBe(test.statusMessage);
            case 12:
            case "end":
              return _context10.stop();
          }
        }, _callee10);
      }));
      return function (_x2) {
        return _ref10.apply(this, arguments);
      };
    }());
  });
  describe('Toolbar', function () {
    it('should render all supported buttons', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee11() {
      var buttons, _render11, driver;
      return _regenerator["default"].wrap(function _callee11$(_context11) {
        while (1) switch (_context11.prev = _context11.next) {
          case 0:
            buttons = ['bold', 'italic', 'underline', 'link', 'unordered-list-item', 'ordered-list-item'];
            _render11 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 175,
                columnNumber: 33
              }
            })), driver = _render11.driver;
            _context11.t0 = expect;
            _context11.next = 5;
            return driver.getButtonTypes();
          case 5:
            _context11.t1 = _context11.sent;
            (0, _context11.t0)(_context11.t1).toEqual(buttons);
          case 7:
          case "end":
            return _context11.stop();
        }
      }, _callee11);
    })));
    describe('Bold', function () {
      var sampleText = 'Bold';
      var sampleValue = "<p><strong>".concat(sampleText, "</strong></p>");
      it('should render text as bold after clicking the bold button', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee12() {
        var _render12, driver;
        return _regenerator["default"].wrap(function _callee12$(_context12) {
          while (1) switch (_context12.prev = _context12.next) {
            case 0:
              _render12 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
                onChange: function onChange(value) {
                  return currentValue = value;
                },
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 186,
                  columnNumber: 11
                }
              })), driver = _render12.driver;
              _context12.next = 3;
              return driver.clickBoldButton();
            case 3:
              _context12.next = 5;
              return driver.enterText(sampleText);
            case 5:
              expect(currentValue).toBe(sampleValue);
            case 6:
            case "end":
              return _context12.stop();
          }
        }, _callee12);
      })));
      it('should render the bold button as active after clicking the button', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee13() {
        var _render13, driver, button;
        return _regenerator["default"].wrap(function _callee13$(_context13) {
          while (1) switch (_context13.prev = _context13.next) {
            case 0:
              _render13 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 196,
                  columnNumber: 35
                }
              })), driver = _render13.driver;
              _context13.next = 3;
              return driver.getBoldButton();
            case 3:
              button = _context13.sent;
              _context13.t0 = expect;
              _context13.next = 7;
              return driver.isActive(button);
            case 7:
              _context13.t1 = _context13.sent;
              (0, _context13.t0)(_context13.t1).toBe(false);
              _context13.next = 11;
              return driver.clickBoldButton();
            case 11:
              _context13.t2 = expect;
              _context13.next = 14;
              return driver.isActive(button);
            case 14:
              _context13.t3 = _context13.sent;
              (0, _context13.t2)(_context13.t3).toBe(true);
            case 16:
            case "end":
              return _context13.stop();
          }
        }, _callee13);
      })));
    });
    describe('Italic', function () {
      var sampleText = 'Italic';
      var sampleValue = "<p><em>".concat(sampleText, "</em></p>");
      it('should render text as italic after clicking the italic button', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee14() {
        var _render14, driver;
        return _regenerator["default"].wrap(function _callee14$(_context14) {
          while (1) switch (_context14.prev = _context14.next) {
            case 0:
              _render14 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
                onChange: function onChange(value) {
                  return currentValue = value;
                },
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 211,
                  columnNumber: 11
                }
              })), driver = _render14.driver;
              _context14.next = 3;
              return driver.clickItalicButton();
            case 3:
              _context14.next = 5;
              return driver.enterText(sampleText);
            case 5:
              expect(currentValue).toBe(sampleValue);
            case 6:
            case "end":
              return _context14.stop();
          }
        }, _callee14);
      })));
      it('should render the italic button as active after clicking the button', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee15() {
        var _render15, driver, button;
        return _regenerator["default"].wrap(function _callee15$(_context15) {
          while (1) switch (_context15.prev = _context15.next) {
            case 0:
              _render15 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 221,
                  columnNumber: 35
                }
              })), driver = _render15.driver;
              _context15.next = 3;
              return driver.getItalicButton();
            case 3:
              button = _context15.sent;
              _context15.t0 = expect;
              _context15.next = 7;
              return driver.isActive(button);
            case 7:
              _context15.t1 = _context15.sent;
              (0, _context15.t0)(_context15.t1).toBe(false);
              _context15.next = 11;
              return driver.clickItalicButton();
            case 11:
              _context15.t2 = expect;
              _context15.next = 14;
              return driver.isActive(button);
            case 14:
              _context15.t3 = _context15.sent;
              (0, _context15.t2)(_context15.t3).toBe(true);
            case 16:
            case "end":
              return _context15.stop();
          }
        }, _callee15);
      })));
    });
    describe('Underline', function () {
      var sampleText = 'Underline';
      var sampleValue = "<p><u>".concat(sampleText, "</u></p>");
      it('should render text with underline after clicking the underline button', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee16() {
        var _render16, driver;
        return _regenerator["default"].wrap(function _callee16$(_context16) {
          while (1) switch (_context16.prev = _context16.next) {
            case 0:
              _render16 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
                onChange: function onChange(value) {
                  return currentValue = value;
                },
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 236,
                  columnNumber: 11
                }
              })), driver = _render16.driver;
              _context16.next = 3;
              return driver.clickUnderlineButton();
            case 3:
              _context16.next = 5;
              return driver.enterText(sampleText);
            case 5:
              expect(currentValue).toBe(sampleValue);
            case 6:
            case "end":
              return _context16.stop();
          }
        }, _callee16);
      })));
      it('should render the underline button as active after clicking the button', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee17() {
        var _render17, driver, button;
        return _regenerator["default"].wrap(function _callee17$(_context17) {
          while (1) switch (_context17.prev = _context17.next) {
            case 0:
              _render17 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 246,
                  columnNumber: 35
                }
              })), driver = _render17.driver;
              _context17.next = 3;
              return driver.getUnderlineButton();
            case 3:
              button = _context17.sent;
              _context17.t0 = expect;
              _context17.next = 7;
              return driver.isActive(button);
            case 7:
              _context17.t1 = _context17.sent;
              (0, _context17.t0)(_context17.t1).toBe(false);
              _context17.next = 11;
              return driver.clickUnderlineButton();
            case 11:
              _context17.t2 = expect;
              _context17.next = 14;
              return driver.isActive(button);
            case 14:
              _context17.t3 = _context17.sent;
              (0, _context17.t2)(_context17.t3).toBe(true);
            case 16:
            case "end":
              return _context17.stop();
          }
        }, _callee17);
      })));
    });
    describe('Bulleted List', function () {
      var sampleText = 'Text';
      var sampleValue = "<ul>\n  <li>".concat(sampleText, "</li>\n</ul>");
      it('should render text as bulleted list after clicking the bulleted list button', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee18() {
        var _render18, driver;
        return _regenerator["default"].wrap(function _callee18$(_context18) {
          while (1) switch (_context18.prev = _context18.next) {
            case 0:
              _render18 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
                onChange: function onChange(value) {
                  return currentValue = value;
                },
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 261,
                  columnNumber: 11
                }
              })), driver = _render18.driver;
              _context18.next = 3;
              return driver.clickBulletedListButton();
            case 3:
              _context18.next = 5;
              return driver.enterText(sampleText);
            case 5:
              expect(currentValue).toBe(sampleValue);
            case 6:
            case "end":
              return _context18.stop();
          }
        }, _callee18);
      })));
      it('should render the bulleted list button as active after clicking the button', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee19() {
        var _render19, driver, button;
        return _regenerator["default"].wrap(function _callee19$(_context19) {
          while (1) switch (_context19.prev = _context19.next) {
            case 0:
              _render19 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 271,
                  columnNumber: 35
                }
              })), driver = _render19.driver;
              _context19.next = 3;
              return driver.getBulletedListButton();
            case 3:
              button = _context19.sent;
              _context19.t0 = expect;
              _context19.next = 7;
              return driver.isActive(button);
            case 7:
              _context19.t1 = _context19.sent;
              (0, _context19.t0)(_context19.t1).toBe(false);
              _context19.next = 11;
              return driver.clickBulletedListButton();
            case 11:
              _context19.t2 = expect;
              _context19.next = 14;
              return driver.isActive(button);
            case 14:
              _context19.t3 = _context19.sent;
              (0, _context19.t2)(_context19.t3).toBe(true);
            case 16:
            case "end":
              return _context19.stop();
          }
        }, _callee19);
      })));
    });
    describe('Numbered List', function () {
      var sampleText = 'Text';
      var sampleValue = "<ol>\n  <li>".concat(sampleText, "</li>\n</ol>");
      it('should render text as numbered list after clicking the numbered list button', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee20() {
        var _render20, driver;
        return _regenerator["default"].wrap(function _callee20$(_context20) {
          while (1) switch (_context20.prev = _context20.next) {
            case 0:
              _render20 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
                onChange: function onChange(value) {
                  return currentValue = value;
                },
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 286,
                  columnNumber: 11
                }
              })), driver = _render20.driver;
              _context20.next = 3;
              return driver.clickNumberedListButton();
            case 3:
              _context20.next = 5;
              return driver.enterText(sampleText);
            case 5:
              expect(currentValue).toBe(sampleValue);
            case 6:
            case "end":
              return _context20.stop();
          }
        }, _callee20);
      })));
      it('should render the numbered list button as active after clicking the button', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee21() {
        var _render21, driver, button;
        return _regenerator["default"].wrap(function _callee21$(_context21) {
          while (1) switch (_context21.prev = _context21.next) {
            case 0:
              _render21 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 296,
                  columnNumber: 35
                }
              })), driver = _render21.driver;
              _context21.next = 3;
              return driver.getNumberedListButton();
            case 3:
              button = _context21.sent;
              _context21.t0 = expect;
              _context21.next = 7;
              return driver.isActive(button);
            case 7:
              _context21.t1 = _context21.sent;
              (0, _context21.t0)(_context21.t1).toBe(false);
              _context21.next = 11;
              return driver.clickNumberedListButton();
            case 11:
              _context21.t2 = expect;
              _context21.next = 14;
              return driver.isActive(button);
            case 14:
              _context21.t3 = _context21.sent;
              (0, _context21.t2)(_context21.t3).toBe(true);
            case 16:
            case "end":
              return _context21.stop();
          }
        }, _callee21);
      })));
    });
    describe('Link', function () {
      var sampleText = 'Link';
      var sampleUrl = 'wix.com';
      it('should render text as link with protocol after clicking the button and inserting required data', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee23() {
        var _render22, driver, sampleValue, isFormDisplayed, linkElement;
        return _regenerator["default"].wrap(function _callee23$(_context23) {
          while (1) switch (_context23.prev = _context23.next) {
            case 0:
              _render22 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
                onChange: function onChange(value) {
                  return currentValue = value;
                },
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 311,
                  columnNumber: 11
                }
              })), driver = _render22.driver;
              sampleValue = "<p><a rel=\"noopener noreferrer\" target=\"_blank\" href=\"http://".concat(sampleUrl, "\">").concat(sampleText, "</a></p>");
              _context23.next = 4;
              return driver.clickLinkButton();
            case 4:
              _context23.next = 6;
              return driver.isFormDisplayed();
            case 6:
              isFormDisplayed = _context23.sent;
              _context23.next = 9;
              return driver.insertLink(sampleText, sampleUrl);
            case 9:
              _context23.next = 11;
              return driver.getLink(sampleText, sampleUrl);
            case 11:
              linkElement = _context23.sent;
              expect(isFormDisplayed).toBe(true);
              expect(currentValue).toBe(sampleValue);
              _context23.next = 16;
              return (0, _react2.waitFor)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee22() {
                return _regenerator["default"].wrap(function _callee22$(_context22) {
                  while (1) switch (_context22.prev = _context22.next) {
                    case 0:
                      _context22.t0 = expect;
                      _context22.next = 3;
                      return driver.isFormDisplayed();
                    case 3:
                      _context22.t1 = _context22.sent;
                      (0, _context22.t0)(_context22.t1).toBe(false);
                    case 5:
                    case "end":
                      return _context22.stop();
                  }
                }, _callee22);
              })));
            case 16:
              _context23.t0 = expect;
              _context23.next = 19;
              return linkElement.attr('target');
            case 19:
              _context23.t1 = _context23.sent;
              (0, _context23.t0)(_context23.t1).toBe('_blank');
              _context23.t2 = expect;
              _context23.next = 24;
              return linkElement.attr('rel');
            case 24:
              _context23.t3 = _context23.sent;
              (0, _context23.t2)(_context23.t3).toContain('noopener noreferrer');
            case 26:
            case "end":
              return _context23.stop();
          }
        }, _callee23);
      })));
      it('should render the link button as active after clicking the button', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee24() {
        var _render23, driver, button;
        return _regenerator["default"].wrap(function _callee24$(_context24) {
          while (1) switch (_context24.prev = _context24.next) {
            case 0:
              _render23 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 330,
                  columnNumber: 35
                }
              })), driver = _render23.driver;
              _context24.next = 3;
              return driver.getLinkButton();
            case 3:
              button = _context24.sent;
              _context24.t0 = expect;
              _context24.next = 7;
              return driver.isActive(button);
            case 7:
              _context24.t1 = _context24.sent;
              (0, _context24.t0)(_context24.t1).toBe(false);
              _context24.next = 11;
              return driver.clickLinkButton();
            case 11:
              _context24.t2 = expect;
              _context24.next = 14;
              return driver.isActive(button);
            case 14:
              _context24.t3 = _context24.sent;
              (0, _context24.t2)(_context24.t3).toBe(true);
            case 16:
            case "end":
              return _context24.stop();
          }
        }, _callee24);
      })));
      it('should render text without link after clicking the button, when the selected text contains a link', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee26() {
        var _render24, driver, sampleValue;
        return _regenerator["default"].wrap(function _callee26$(_context26) {
          while (1) switch (_context26.prev = _context26.next) {
            case 0:
              _render24 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
                onChange: function onChange(value) {
                  return currentValue = value;
                },
                __self: _this,
                __source: {
                  fileName: _jsxFileName,
                  lineNumber: 340,
                  columnNumber: 11
                }
              })), driver = _render24.driver;
              sampleValue = "<p>".concat(sampleText, "</p>");
              _context26.next = 4;
              return driver.clickLinkButton();
            case 4:
              _context26.next = 6;
              return driver.insertLink(sampleText, sampleUrl);
            case 6:
              _context26.next = 8;
              return driver.clickLinkButton();
            case 8:
              _context26.next = 10;
              return (0, _react2.waitFor)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee25() {
                return _regenerator["default"].wrap(function _callee25$(_context25) {
                  while (1) switch (_context25.prev = _context25.next) {
                    case 0:
                      _context25.t0 = expect;
                      _context25.next = 3;
                      return driver.isFormDisplayed();
                    case 3:
                      _context25.t1 = _context25.sent;
                      (0, _context25.t0)(_context25.t1).toBe(false);
                    case 5:
                    case "end":
                      return _context25.stop();
                  }
                }, _callee25);
              })));
            case 10:
              expect(currentValue).toBe(sampleValue);
            case 11:
            case "end":
              return _context26.stop();
          }
        }, _callee26);
      })));
      it.each([['Email', 'mailto:test@test.com'], ['Number', 'tel:1234567890'], ['SMS', 'sms:1234567890']])('should not prepend %s with http', /*#__PURE__*/function () {
        var _ref27 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee27(text, url) {
          var onChangeMock, _render25, driver, sampleValue;
          return _regenerator["default"].wrap(function _callee27$(_context27) {
            while (1) switch (_context27.prev = _context27.next) {
              case 0:
                onChangeMock = vi.fn();
                _render25 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
                  onChange: onChangeMock,
                  __self: _this,
                  __source: {
                    fileName: _jsxFileName,
                    lineNumber: 361,
                    columnNumber: 11
                  }
                })), driver = _render25.driver;
                sampleValue = "<p><a href=\"".concat(url, "\">").concat(text, "</a></p>");
                _context27.next = 5;
                return driver.clickLinkButton();
              case 5:
                _context27.next = 7;
                return driver.insertLink(text, url);
              case 7:
                expect(onChangeMock).toHaveBeenLastCalledWith(sampleValue, {
                  plainText: text
                });
              case 8:
              case "end":
                return _context27.stop();
            }
          }, _callee27);
        }));
        return function (_x3, _x4) {
          return _ref27.apply(this, arguments);
        };
      }());
    });
    it('should disable the confirm button within the insertion form when url is empty', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee28() {
      var _render26, driver;
      return _regenerator["default"].wrap(function _callee28$(_context28) {
        while (1) switch (_context28.prev = _context28.next) {
          case 0:
            _render26 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 374,
                columnNumber: 33
              }
            })), driver = _render26.driver;
            _context28.next = 3;
            return driver.clickLinkButton();
          case 3:
            _context28.t0 = expect;
            _context28.next = 6;
            return driver.isFormConfirmButtonDisabled();
          case 6:
            _context28.t1 = _context28.sent;
            (0, _context28.t0)(_context28.t1).toBe(true);
          case 8:
          case "end":
            return _context28.stop();
        }
      }, _callee28);
    })));
    it('should enable the confirm button within the insertion form when url is entered', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee29() {
      var _render27, driver;
      return _regenerator["default"].wrap(function _callee29$(_context29) {
        while (1) switch (_context29.prev = _context29.next) {
          case 0:
            _render27 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 382,
                columnNumber: 33
              }
            })), driver = _render27.driver;
            _context29.next = 3;
            return driver.clickLinkButton();
          case 3:
            _context29.next = 5;
            return driver.insertUrl('Some URL');
          case 5:
            _context29.t0 = expect;
            _context29.next = 8;
            return driver.isFormConfirmButtonDisabled();
          case 8:
            _context29.t1 = _context29.sent;
            (0, _context29.t0)(_context29.t1).toBe(false);
          case 10:
          case "end":
            return _context29.stop();
        }
      }, _callee29);
    })));
    it('should hide the insertion form after clicking the cancel button', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee31() {
      var _render28, driver;
      return _regenerator["default"].wrap(function _callee31$(_context31) {
        while (1) switch (_context31.prev = _context31.next) {
          case 0:
            _render28 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 391,
                columnNumber: 33
              }
            })), driver = _render28.driver;
            _context31.next = 3;
            return driver.clickLinkButton();
          case 3:
            _context31.next = 5;
            return driver.clickFormCancelButton();
          case 5:
            _context31.next = 7;
            return (0, _react2.waitFor)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee30() {
              return _regenerator["default"].wrap(function _callee30$(_context30) {
                while (1) switch (_context30.prev = _context30.next) {
                  case 0:
                    _context30.t0 = expect;
                    _context30.next = 3;
                    return driver.isFormDisplayed();
                  case 3:
                    _context30.t1 = _context30.sent;
                    (0, _context30.t0)(_context30.t1).toBe(false);
                  case 5:
                  case "end":
                    return _context30.stop();
                }
              }, _callee30);
            })));
          case 7:
          case "end":
            return _context31.stop();
        }
      }, _callee31);
    })));
    it('should set value to given value', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee33() {
      var onChange, myRef, _render29, driver;
      return _regenerator["default"].wrap(function _callee33$(_context33) {
        while (1) switch (_context33.prev = _context33.next) {
          case 0:
            onChange = vi.fn();
            myRef = null;
            _render29 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
              initialValue: "something old",
              ref: function ref(_ref33) {
                myRef = _ref33;
              },
              onChange: onChange,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 405,
                columnNumber: 9
              }
            })), driver = _render29.driver;
            _context33.t0 = expect;
            _context33.next = 6;
            return driver.getContent();
          case 6:
            _context33.t1 = _context33.sent;
            (0, _context33.t0)(_context33.t1).toEqual('something old');
            _context33.next = 10;
            return (0, _react2.act)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee32() {
              return _regenerator["default"].wrap(function _callee32$(_context32) {
                while (1) switch (_context32.prev = _context32.next) {
                  case 0:
                    myRef.setValue('something new');
                  case 1:
                  case "end":
                    return _context32.stop();
                }
              }, _callee32);
            })));
          case 10:
            _context33.t2 = expect;
            _context33.next = 13;
            return driver.getContent();
          case 13:
            _context33.t3 = _context33.sent;
            (0, _context33.t2)(_context33.t3).toEqual('something new');
          case 15:
          case "end":
            return _context33.stop();
        }
      }, _callee33);
    })));
    it('should set value to empty value', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee35() {
      var onChange, myRef, _render30, driver;
      return _regenerator["default"].wrap(function _callee35$(_context35) {
        while (1) switch (_context35.prev = _context35.next) {
          case 0:
            onChange = vi.fn();
            myRef = null;
            _render30 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
              initialValue: "something old",
              ref: function ref(_ref36) {
                myRef = _ref36;
              },
              onChange: onChange,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 425,
                columnNumber: 9
              }
            })), driver = _render30.driver;
            _context35.t0 = expect;
            _context35.next = 6;
            return driver.getContent();
          case 6:
            _context35.t1 = _context35.sent;
            (0, _context35.t0)(_context35.t1).toEqual('something old');
            _context35.next = 10;
            return (0, _react2.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:
                    myRef.setValue('');
                  case 1:
                  case "end":
                    return _context34.stop();
                }
              }, _callee34);
            })));
          case 10:
            _context35.t2 = expect;
            _context35.next = 13;
            return driver.getContent();
          case 13:
            _context35.t3 = _context35.sent;
            (0, _context35.t2)(_context35.t3).toEqual('');
          case 15:
          case "end":
            return _context35.stop();
        }
      }, _callee35);
    })));
    it('should focus element on focus() call', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee37() {
      var elementRef, _render31, driver;
      return _regenerator["default"].wrap(function _callee37$(_context37) {
        while (1) switch (_context37.prev = _context37.next) {
          case 0:
            elementRef = null;
            _render31 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
              ref: function ref(_ref39) {
                elementRef = _ref39;
              },
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 444,
                columnNumber: 9
              }
            })), driver = _render31.driver;
            _context37.next = 4;
            return (0, _react2.act)(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee36() {
              return _regenerator["default"].wrap(function _callee36$(_context36) {
                while (1) switch (_context36.prev = _context36.next) {
                  case 0:
                    elementRef.focus();
                  case 1:
                  case "end":
                    return _context36.stop();
                }
              }, _callee36);
            })));
          case 4:
            _context37.t0 = expect;
            _context37.next = 7;
            return driver.hasFocus();
          case 7:
            _context37.t1 = _context37.sent;
            (0, _context37.t0)(_context37.t1).toBe(true);
          case 9:
          case "end":
            return _context37.stop();
        }
      }, _callee37);
    })));
    it('should blur element on blur() call', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee39() {
      var elementRef, _render32, driver;
      return _regenerator["default"].wrap(function _callee39$(_context39) {
        while (1) switch (_context39.prev = _context39.next) {
          case 0:
            elementRef = null;
            _render32 = render(/*#__PURE__*/_react["default"].createElement(_RichTextInputArea["default"], {
              ref: function ref(_ref42) {
                elementRef = _ref42;
              },
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 460,
                columnNumber: 9
              }
            })), driver = _render32.driver;
            _context39.next = 4;
            return (0, _react2.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:
                    elementRef.focus();
                    elementRef.blur();
                  case 2:
                  case "end":
                    return _context38.stop();
                }
              }, _callee38);
            })));
          case 4:
            _context39.t0 = expect;
            _context39.next = 7;
            return driver.hasFocus();
          case 7:
            _context39.t1 = _context39.sent;
            (0, _context39.t0)(_context39.t1).toBe(false);
          case 9:
          case "end":
            return _context39.stop();
        }
      }, _callee39);
    })));
  });
});