40.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. import HeadingEditing from '../../src/headingediting';
  6. import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
  7. import Enter from '@ckeditor/ckeditor5-enter/src/enter';
  8. import { getData, setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
  9. describe( 'Bug ckeditor5-heading#40', () => {
  10. let editor;
  11. afterEach( () => {
  12. return editor.destroy();
  13. } );
  14. it( 'enter at the end of a heading creates a paragraph, when heading was loaded before enter', () => {
  15. return VirtualTestEditor
  16. .create( {
  17. plugins: [ HeadingEditing, Enter ]
  18. } )
  19. .then( newEditor => {
  20. editor = newEditor;
  21. setData( editor.model, '<heading1>foo[]</heading1>' );
  22. editor.execute( 'enter' );
  23. expect( getData( editor.model ) ).to.equal( '<heading1>foo</heading1><paragraph>[]</paragraph>' );
  24. } );
  25. } );
  26. it( 'enter at the end of a heading creates a paragraph, when enter was loaded before heading', () => {
  27. return VirtualTestEditor
  28. .create( {
  29. plugins: [ Enter, HeadingEditing ]
  30. } )
  31. .then( newEditor => {
  32. editor = newEditor;
  33. setData( editor.model, '<heading1>foo[]</heading1>' );
  34. editor.execute( 'enter' );
  35. expect( getData( editor.model ) ).to.equal( '<heading1>foo</heading1><paragraph>[]</paragraph>' );
  36. } );
  37. } );
  38. } );