8
0

horizontal_rules.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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, parse } from '/tests/engine/_utils/view.js';
  7. describe( 'GFMDataProcessor', () => {
  8. let dataProcessor;
  9. beforeEach( () => {
  10. dataProcessor = new MarkdownDataProcessor();
  11. } );
  12. describe( 'horizontal rules', () => {
  13. describe( 'toView', () => {
  14. describe( 'dashes', () => {
  15. it( '#1', () => {
  16. const viewFragment = dataProcessor.toView( '---' );
  17. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  18. } );
  19. it( '#2', () => {
  20. const viewFragment = dataProcessor.toView( ' ---' );
  21. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  22. } );
  23. it( '#3', () => {
  24. const viewFragment = dataProcessor.toView( ' ---' );
  25. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  26. } );
  27. it( '#4', () => {
  28. const viewFragment = dataProcessor.toView( ' ---' );
  29. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  30. } );
  31. it( '#5 - code', () => {
  32. const viewFragment = dataProcessor.toView( ' ---' );
  33. expect( stringify( viewFragment ) ).to.equal( '<pre><code>---</code></pre>' );
  34. } );
  35. } );
  36. describe( 'dashes with spaces', () => {
  37. it( '#1', () => {
  38. const viewFragment = dataProcessor.toView( '- - -' );
  39. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  40. } );
  41. it( '#2', () => {
  42. const viewFragment = dataProcessor.toView( ' - - -' );
  43. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  44. } );
  45. it( '#3', () => {
  46. const viewFragment = dataProcessor.toView( ' - - -' );
  47. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  48. } );
  49. it( '#4', () => {
  50. const viewFragment = dataProcessor.toView( ' - - -' );
  51. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  52. } );
  53. it( '#5 - code', () => {
  54. const viewFragment = dataProcessor.toView( ' - - -' );
  55. expect( stringify( viewFragment ) ).to.equal( '<pre><code>- - -</code></pre>' );
  56. } );
  57. } );
  58. describe( 'asterisks', () => {
  59. it( '#1', () => {
  60. const viewFragment = dataProcessor.toView( '***' );
  61. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  62. } );
  63. it( '#2', () => {
  64. const viewFragment = dataProcessor.toView( ' ***' );
  65. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  66. } );
  67. it( '#3', () => {
  68. const viewFragment = dataProcessor.toView( ' ***' );
  69. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  70. } );
  71. it( '#4', () => {
  72. const viewFragment = dataProcessor.toView( ' ***' );
  73. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  74. } );
  75. it( '#5 - code', () => {
  76. const viewFragment = dataProcessor.toView( ' ***' );
  77. expect( stringify( viewFragment ) ).to.equal( '<pre><code>***</code></pre>' );
  78. } );
  79. } );
  80. describe( 'asterisks with spaces', () => {
  81. it( '#1', () => {
  82. const viewFragment = dataProcessor.toView( '* * *' );
  83. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  84. } );
  85. it( '#2', () => {
  86. const viewFragment = dataProcessor.toView( ' * * *' );
  87. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  88. } );
  89. it( '#3', () => {
  90. const viewFragment = dataProcessor.toView( ' * * *' );
  91. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  92. } );
  93. it( '#4', () => {
  94. const viewFragment = dataProcessor.toView( ' * * *' );
  95. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  96. } );
  97. it( '#5 - code', () => {
  98. const viewFragment = dataProcessor.toView( ' * * *' );
  99. expect( stringify( viewFragment ) ).to.equal( '<pre><code>* * *</code></pre>' );
  100. } );
  101. } );
  102. describe( 'underscores', () => {
  103. it( '#1', () => {
  104. const viewFragment = dataProcessor.toView( '___' );
  105. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  106. } );
  107. it( '#2', () => {
  108. const viewFragment = dataProcessor.toView( ' ___' );
  109. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  110. } );
  111. it( '#3', () => {
  112. const viewFragment = dataProcessor.toView( ' ___' );
  113. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  114. } );
  115. it( '#4', () => {
  116. const viewFragment = dataProcessor.toView( ' ___' );
  117. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  118. } );
  119. it( '#5 - code', () => {
  120. const viewFragment = dataProcessor.toView( ' ___' );
  121. expect( stringify( viewFragment ) ).to.equal( '<pre><code>___</code></pre>' );
  122. } );
  123. } );
  124. describe( 'underscores with spaces', () => {
  125. it( '#1', () => {
  126. const viewFragment = dataProcessor.toView( '_ _ _' );
  127. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  128. } );
  129. it( '#2', () => {
  130. const viewFragment = dataProcessor.toView( ' _ _ _' );
  131. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  132. } );
  133. it( '#3', () => {
  134. const viewFragment = dataProcessor.toView( ' _ _ _' );
  135. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  136. } );
  137. it( '#4', () => {
  138. const viewFragment = dataProcessor.toView( ' _ _ _' );
  139. expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
  140. } );
  141. it( '#5 - code', () => {
  142. const viewFragment = dataProcessor.toView( ' _ _ _' );
  143. expect( stringify( viewFragment ) ).to.equal( '<pre><code>_ _ _</code></pre>' );
  144. } );
  145. } );
  146. } );
  147. describe( 'toData', () => {
  148. it( 'should process horizontal rules', () => {
  149. const viewFragment = parse( '<hr></hr>' );
  150. expect( dataProcessor.toData( viewFragment ) ).to.equal( '* * *' );
  151. } );
  152. } );
  153. } );
  154. } );