articlepluginset.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* global document */
  6. import ArticlePluginSet from '../_utils/articlepluginset';
  7. import ClassicTestEditor from '../_utils/classictesteditor';
  8. import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials';
  9. import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
  10. import Autoformat from '@ckeditor/ckeditor5-autoformat/src/autoformat';
  11. import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';
  12. import Heading from '@ckeditor/ckeditor5-heading/src/heading';
  13. import Image from '@ckeditor/ckeditor5-image/src/image';
  14. import ImageCaption from '@ckeditor/ckeditor5-image/src/imagecaption';
  15. import ImageStyle from '@ckeditor/ckeditor5-image/src/imagestyle';
  16. import ImageToolbar from '@ckeditor/ckeditor5-image/src/imagetoolbar';
  17. import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';
  18. import Link from '@ckeditor/ckeditor5-link/src/link';
  19. import List from '@ckeditor/ckeditor5-list/src/list';
  20. import normalizeHtml from '@ckeditor/ckeditor5-utils/tests/_utils/normalizehtml';
  21. describe( 'ArticlePluginSet', () => {
  22. let editor, editorElement;
  23. beforeEach( () => {
  24. editorElement = document.createElement( 'div' );
  25. document.body.appendChild( editorElement );
  26. return ClassicTestEditor.create( editorElement, { plugins: [ ArticlePluginSet ] } )
  27. .then( newEditor => {
  28. editor = newEditor;
  29. } );
  30. } );
  31. afterEach( () => {
  32. editor.destroy();
  33. editorElement.remove();
  34. } );
  35. it( 'should be loaded', () => {
  36. expect( editor.plugins.get( ArticlePluginSet ) ).to.be.instanceOf( ArticlePluginSet );
  37. } );
  38. it( 'should load all its dependencies', () => {
  39. expect( editor.plugins.get( Essentials ) ).to.be.instanceOf( Essentials );
  40. expect( editor.plugins.get( Paragraph ) ).to.be.instanceOf( Paragraph );
  41. expect( editor.plugins.get( Autoformat ) ).to.be.instanceOf( Autoformat );
  42. expect( editor.plugins.get( Bold ) ).to.be.instanceOf( Bold );
  43. expect( editor.plugins.get( Heading ) ).to.be.instanceOf( Heading );
  44. expect( editor.plugins.get( Image ) ).to.be.instanceOf( Image );
  45. expect( editor.plugins.get( ImageCaption ) ).to.be.instanceOf( ImageCaption );
  46. expect( editor.plugins.get( ImageStyle ) ).to.be.instanceOf( ImageStyle );
  47. expect( editor.plugins.get( ImageToolbar ) ).to.be.instanceOf( ImageToolbar );
  48. expect( editor.plugins.get( Italic ) ).to.be.instanceOf( Italic );
  49. expect( editor.plugins.get( Link ) ).to.be.instanceOf( Link );
  50. expect( editor.plugins.get( List ) ).to.be.instanceOf( List );
  51. } );
  52. it( 'loads data', () => {
  53. const data =
  54. '<h2>Heading 1</h2>' +
  55. '<p>Paragraph</p>' +
  56. '<p><strong>Bold</strong> <i>Italic</i> <a href="foo">Link</a></p>' +
  57. '<ul>' +
  58. '<li>UL List item 1</li>' +
  59. '<li>UL List item 2</li>' +
  60. '</ul>' +
  61. '<ol>' +
  62. '<li>OL List item 1</li>' +
  63. '<li>OL List item 2</li>' +
  64. '</ol>' +
  65. '<figure class="image image-style-side">' +
  66. '<img alt="bar" src="foo">' +
  67. '<figcaption>Caption</figcaption>' +
  68. '</figure>' +
  69. '<blockquote>' +
  70. '<p>Quote</p>' +
  71. '<ul><li>Quoted UL List item 1</li></ul>' +
  72. '</blockquote>';
  73. // Can't use data twice due to https://github.com/ckeditor/ckeditor5-utils/issues/128.
  74. const expectedOutput =
  75. '<h2>Heading 1</h2>' +
  76. '<p>Paragraph</p>' +
  77. '<p><strong>Bold</strong> <i>Italic</i> <a href="foo">Link</a></p>' +
  78. '<ul>' +
  79. '<li>UL List item 1</li>' +
  80. '<li>UL List item 2</li>' +
  81. '</ul>' +
  82. '<ol>' +
  83. '<li>OL List item 1</li>' +
  84. '<li>OL List item 2</li>' +
  85. '</ol>' +
  86. '<figure class="image image-style-side">' +
  87. '<img alt="bar" src="foo"></img>' +
  88. '<figcaption>Caption</figcaption>' +
  89. '</figure>' +
  90. '<blockquote>' +
  91. '<p>Quote</p>' +
  92. '<ul><li>Quoted UL List item 1</li></ul>' +
  93. '</blockquote>';
  94. editor.setData( data );
  95. expect( normalizeHtml( editor.getData() ) ).to.equal( expectedOutput );
  96. } );
  97. } );