8
0

strong_and_emphasis.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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( 'strong and emphasis', () => {
  13. describe( 'toView', () => {
  14. it( 'should process strong', () => {
  15. const viewFragment = dataProcessor.toView( '**this is strong** and __this too__' );
  16. expect( stringify( viewFragment ) ).to.equal( '<p><strong>this is strong</strong> and <strong>this too</strong></p>' );
  17. } );
  18. it( 'should process emphasis', () => {
  19. const viewFragment = dataProcessor.toView( '*this is emphasis* and _this too_' );
  20. expect( stringify( viewFragment ) ).to.equal( '<p><em>this is emphasis</em> and <em>this too</em></p>' );
  21. } );
  22. it( 'should process strong and emphasis together #1', () => {
  23. const viewFragment = dataProcessor.toView( '***This is strong and em.***' );
  24. expect( stringify( viewFragment ) ).to.equal( '<p><strong><em>This is strong and em.</em></strong></p>' );
  25. } );
  26. it( 'should process strong and emphasis together #2', () => {
  27. const viewFragment = dataProcessor.toView( 'Single ***word*** is strong and em.' );
  28. expect( stringify( viewFragment ) ).to.equal( '<p>Single <strong><em>word</em></strong> is strong and em.</p>' );
  29. } );
  30. it( 'should process strong and emphasis together #3', () => {
  31. const viewFragment = dataProcessor.toView( '___This is strong and em.___' );
  32. expect( stringify( viewFragment ) ).to.equal( '<p><strong><em>This is strong and em.</em></strong></p>' );
  33. } );
  34. it( 'should process strong and emphasis together #4', () => {
  35. const viewFragment = dataProcessor.toView( 'Single ___word___ is strong and em.' );
  36. expect( stringify( viewFragment ) ).to.equal( '<p>Single <strong><em>word</em></strong> is strong and em.</p>' );
  37. } );
  38. it( 'should not process emphasis inside words', () => {
  39. const viewFragment = dataProcessor.toView( 'This should_not_be_emp.' );
  40. expect( stringify( viewFragment ) ).to.equal( '<p>This should_not_be_emp.</p>' );
  41. } );
  42. it( 'should process nested emphasis #1', () => {
  43. const viewFragment = dataProcessor.toView( '*test **test** test*' );
  44. expect( stringify( viewFragment ) ).to.equal( '<p><em>test <strong>test</strong> test</em></p>' );
  45. } );
  46. it( 'should process nested emphasis #2', () => {
  47. const viewFragment = dataProcessor.toView( '_test __test__ test_' );
  48. expect( stringify( viewFragment ) ).to.equal( '<p><em>test <strong>test</strong> test</em></p>' );
  49. } );
  50. } );
  51. } );
  52. } );