import Licit, { DataType } from './Licit';
import RichTextEditor from '../ui/RichTextEditor';
import { noop } from '@modusoperandi/licit-ui-commands';
describe('<Licit />', function () {
  var data = {
    type: 'doc',
    content: [{
      type: 'paragraph',
      content: [{
        type: 'text',
        text: ' '
      }]
    }],
    onReady: function onReady() {},
    autoFocus: true,
    children: '',
    className: 'licit',
    disabled: true
  };
  var fakeEditorView = {
    focus: noop,
    dispatch: noop,
    state: {
      doc: {
        content: {
          size: 10
        },
        resolve: function resolve() {
          return {
            min: function min() {
              return 0;
            },
            max: function max() {
              return 10;
            },
            parent: {
              inlineContent: true
            }
          };
        },
        toJSON: function toJSON() {
          return data;
        }
      },
      tr: {
        setSelection: function setSelection() {
          return fakeEditorView.state.tr;
        },
        scrollIntoView: noop
      }
    }
  };
  it('should render a <RichTextEditor /> ', function () {
    var wrapper = new RichTextEditor({
      data: data
    });
    wrapper.props = {
      type: 'doc',
      content: [{
        type: 'paragraph',
        content: [{
          type: 'text',
          text: ' '
        }]
      }],
      onReady: function onReady() {},
      autoFocus: true,
      children: '',
      className: 'licit',
      disabled: true
    };
    expect(wrapper.render()).toBeTruthy();
  });
  describe('editorView (getter)', function () {
    it('should return the prosemirror view', function () {
      var wrapper = new RichTextEditor({
        data: data
      });
      wrapper.props = {
        type: 'doc',
        content: [{
          type: 'paragraph',
          content: [{
            type: 'text',
            text: ' '
          }]
        }],
        onReady: function onReady() {},
        autoFocus: true,
        children: '',
        className: 'licit',
        disabled: true
      };
      expect(wrapper._onReady(fakeEditorView)).toBeUndefined();
    });
  });
});
describe('<Licit with HTML input/>', function () {
  var wrapper;
  var HELLO = 'Hello ';
  var WORLD = 'World';
  var data = '<p stylename="None">' + HELLO + '<strong overridden="false">' + WORLD + '</strong></p>';
  beforeEach(function () {
    wrapper = new Licit({
      data: data
    }, DataType.HTML);
  });
  it('should render a <RichTextEditor /> ', function () {
    expect(wrapper.render()).toBeTruthy();
  });
  it('should match state text content with the passed in text ', function () {
    expect(wrapper.state.editorState.doc.textContent).toBe('');
  });
});