8
0

shiftenter-integration.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* global document */
  6. import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
  7. import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
  8. import ShiftEnter from '../src/shiftenter';
  9. import { getData as getModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
  10. import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
  11. describe( 'ShiftEnter integration', () => {
  12. let editor, model, div;
  13. beforeEach( () => {
  14. div = document.createElement( 'div' );
  15. div.innerHTML = '<p>First line.<br>Second line.</p>';
  16. document.body.appendChild( div );
  17. return ClassicEditor.create( div, { plugins: [ Paragraph, ShiftEnter ] } )
  18. .then( newEditor => {
  19. editor = newEditor;
  20. model = editor.model;
  21. } );
  22. } );
  23. afterEach( () => {
  24. div.remove();
  25. return editor.destroy();
  26. } );
  27. it( 'loads correct data', () => {
  28. const options = { withoutSelection: true };
  29. expect( getModelData( model, options) ).to.equal( '<paragraph>First line.<break></break>Second line.</paragraph>' );
  30. expect( getViewData( editor.editing.view, options ) ).to.equal( '<p>First line.<br></br>Second line.</p>' );
  31. } );
  32. } );