paragraphs.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import MarkdownDataProcessor from '/ckeditor5/markdown-gfm/gfmdataprocessor.js';
  6. import { stringify } from '/tests/engine/_utils/view.js';
  7. describe( 'GFMDataProcessor', () => {
  8. let dataProcessor;
  9. beforeEach( () => {
  10. dataProcessor = new MarkdownDataProcessor();
  11. } );
  12. describe( 'paragraphs', () => {
  13. describe( 'toView', () => {
  14. it( 'single line', () => {
  15. const viewFragment = dataProcessor.toView( 'single line paragraph' );
  16. expect( stringify( viewFragment ) ).to.equal( '<p>single line paragraph</p>' );
  17. } );
  18. it( 'multiline', () => {
  19. const viewFragment = dataProcessor.toView( 'first\n second\n third' );
  20. expect( stringify( viewFragment ) ).to.equal( '<p>first<br></br> second<br></br> third</p>' );
  21. } );
  22. it( 'with header after #1', () => {
  23. const viewFragment = dataProcessor.toView( 'single line\n# header' );
  24. expect( stringify( viewFragment ) ).to.equal( '<p>single line</p><h1 id="header">header</h1>' );
  25. } );
  26. it( 'with header after #2', () => {
  27. const viewFragment = dataProcessor.toView( 'single line\nheader\n===' );
  28. expect( stringify( viewFragment ) ).to.equal( '<p>single line</p><h1 id="header">header</h1>' );
  29. } );
  30. it( 'with blockquote after', () => {
  31. const viewFragment = dataProcessor.toView( 'single line\n> quote' );
  32. expect( stringify( viewFragment ) ).to.equal( '<p>single line</p><blockquote><p>quote</p></blockquote>' );
  33. } );
  34. it( 'with list after', () => {
  35. const viewFragment = dataProcessor.toView( 'single line\n* item' );
  36. expect( stringify( viewFragment ) ).to.equal( '<p>single line</p><ul><li>item</li></ul>' );
  37. } );
  38. it( 'with div element after', () => {
  39. const viewFragment = dataProcessor.toView( 'single line\n<div>div element</div>' );
  40. expect( stringify( viewFragment ) ).to.equal( '<p>single line</p><div>div element</div>' );
  41. } );
  42. } );
  43. } );
  44. } );