"use strict";

var _react = _interopRequireDefault(require("react"));

var _enzyme = require("enzyme");

var _enzymeAdapterReact = _interopRequireDefault(require("enzyme-adapter-react-16"));

var _Licit = _interopRequireDefault(require("./Licit"));

var _RichTextEditor = _interopRequireDefault(require("../ui/RichTextEditor"));

var _noop = _interopRequireDefault(require("../noop"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
 * Configure Jest to use react / enzyme
 */
(0, _enzyme.configure)({
  adapter: new _enzymeAdapterReact.default()
});
describe('<Licit />', () => {
  let wrapper;
  let licit; // Mocking the functions used in _onReady

  const fakeEditorView = {
    focus: _noop.default,
    dispatch: _noop.default,
    state: {
      doc: {
        content: {
          size: 10
        },
        resolve: () => ({
          min: () => 0,
          max: () => 10
        })
      },
      tr: {
        setSelection: () => fakeEditorView.state.tr,
        scrollIntoView: _noop.default
      }
    }
  };
  beforeEach(() => {
    // provide an empty document just to shut up that warning
    const data = {
      type: 'doc',
      content: [{
        type: 'paragraph',
        content: [{
          type: 'text',
          text: ' '
        }]
      }]
    };
    wrapper = (0, _enzyme.shallow)( /*#__PURE__*/_react.default.createElement(_Licit.default, {
      data: data
    }));
    licit = wrapper.instance();
  });
  it('should render a <RichTextEditor /> ', () => {
    expect(wrapper.find(_RichTextEditor.default)).toBeTruthy();
  });
  describe('editorView (getter)', () => {
    it('should return the prosemirror view', () => {
      // Using shallow, the underlying RichTexEditor is never really created,
      // and Licit's _onReady method is not called.  Call it here with the fake
      // view created above
      licit._onReady(fakeEditorView); // Verify that getter now returns the underlying view.


      expect(licit.editorView).toBe(fakeEditorView);
    });
  });
});