headers.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 { testDataProcessor } from '../_utils/utils';
  6. describe( 'GFMDataProcessor', () => {
  7. describe( 'headers', () => {
  8. it( 'should process level 1 header #1', () => {
  9. testDataProcessor(
  10. '# Level 1',
  11. '<h1>Level 1</h1>'
  12. );
  13. } );
  14. it( 'should process level 1 header #2', () => {
  15. testDataProcessor(
  16. 'Level 1\n' +
  17. '===',
  18. '<h1>Level 1</h1>',
  19. // When converting back it will be normalized to # representation.
  20. '# Level 1'
  21. );
  22. } );
  23. it( 'should process level 2 header #1', () => {
  24. testDataProcessor(
  25. '## Level 2',
  26. '<h2>Level 2</h2>'
  27. );
  28. } );
  29. it( 'should process level 2 header #2', () => {
  30. testDataProcessor(
  31. 'Level 2\n' +
  32. '---',
  33. '<h2>Level 2</h2>',
  34. // When converting back it will be normalized to ## representation.
  35. '## Level 2'
  36. );
  37. } );
  38. it( 'should process level 3 header', () => {
  39. testDataProcessor(
  40. '### Level 3',
  41. '<h3>Level 3</h3>'
  42. );
  43. } );
  44. it( 'should process level 4 header', () => {
  45. testDataProcessor(
  46. '#### Level 4',
  47. '<h4>Level 4</h4>'
  48. );
  49. } );
  50. it( 'should process level 5 header', () => {
  51. testDataProcessor(
  52. '##### Level 5',
  53. '<h5>Level 5</h5>'
  54. );
  55. } );
  56. it( 'should process level 6 header', () => {
  57. testDataProcessor(
  58. '###### Level 6',
  59. '<h6>Level 6</h6>'
  60. );
  61. } );
  62. it( 'should create header when more spaces before text', () => {
  63. testDataProcessor(
  64. '# Level 1',
  65. '<h1>Level 1</h1>',
  66. // When converting back it will be normalized to # Level 1.
  67. '# Level 1'
  68. );
  69. } );
  70. it( 'should process headers placed next to each other #1', () => {
  71. testDataProcessor(
  72. '# header\n' +
  73. '# header',
  74. '<h1>header</h1><h1>header</h1>',
  75. '# header\n' +
  76. '\n' +
  77. '# header'
  78. );
  79. } );
  80. it( 'should process headers placed next to each other #2', () => {
  81. testDataProcessor(
  82. '# header\n' +
  83. '## header\n' +
  84. '### header',
  85. '<h1>header</h1><h2>header</h2><h3>header</h3>',
  86. '# header\n' +
  87. '\n' +
  88. '## header\n' +
  89. '\n' +
  90. '### header'
  91. );
  92. } );
  93. it( 'should process headers followed by a paragraph', () => {
  94. testDataProcessor(
  95. '# header\n\n' +
  96. 'paragraph',
  97. '<h1>header</h1><p>paragraph</p>'
  98. );
  99. } );
  100. } );
  101. } );