8
0

integration.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 Alignment from '../src/alignment';
  7. import BlockQuote from '@ckeditor/ckeditor5-block-quote/src/blockquote';
  8. import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
  9. import Heading from '@ckeditor/ckeditor5-heading/src/heading';
  10. import Image from '@ckeditor/ckeditor5-image/src/image';
  11. import ImageCaption from '@ckeditor/ckeditor5-image/src/imagecaption';
  12. import List from '@ckeditor/ckeditor5-list/src/list';
  13. import Enter from '@ckeditor/ckeditor5-enter/src/enter';
  14. import Delete from '@ckeditor/ckeditor5-typing/src/delete';
  15. import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
  16. import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
  17. describe( 'Alignment', () => {
  18. let editor, doc, element;
  19. beforeEach( () => {
  20. element = document.createElement( 'div' );
  21. document.body.appendChild( element );
  22. return ClassicTestEditor
  23. .create( element, {
  24. plugins: [ Alignment, BlockQuote, Paragraph, Heading, Image, ImageCaption, List, Enter, Delete ]
  25. } )
  26. .then( newEditor => {
  27. editor = newEditor;
  28. doc = editor.document;
  29. } );
  30. } );
  31. afterEach( () => {
  32. element.remove();
  33. return editor.destroy();
  34. } );
  35. describe( 'compatibility with images', () => {
  36. it( 'does not work inside image caption', () => {
  37. setModelData( doc, '<image src="foo.png"><caption>Foo[]</caption></image>' );
  38. editor.execute( 'alignCenter' );
  39. expect( getModelData( doc ) ).to.equal( '<image src="foo.png"><caption>Foo[]</caption></image>' );
  40. } );
  41. } );
  42. describe( 'compatibility with blockQuote', () => {
  43. it( 'does work inside BlockQuote on paragraph', () => {
  44. setModelData( doc, '<blockQuote><paragraph>Foo[]</paragraph></blockQuote>' );
  45. editor.execute( 'alignCenter' );
  46. expect( getModelData( doc ) ).to.equal( '<blockQuote><paragraph alignment="center">Foo[]</paragraph></blockQuote>' );
  47. } );
  48. it( 'does work inside blockQuote on heading', () => {
  49. setModelData( doc, '<blockQuote><heading1>Foo[]</heading1></blockQuote>' );
  50. editor.execute( 'alignCenter' );
  51. expect( getModelData( doc ) ).to.equal( '<blockQuote><heading1 alignment="center">Foo[]</heading1></blockQuote>' );
  52. } );
  53. it( 'does work inside blockQuote on listItem', () => {
  54. setModelData( doc, '<blockQuote><listItem indent="0" type="numbered">Foo[]</listItem></blockQuote>' );
  55. editor.execute( 'alignCenter' );
  56. expect( getModelData( doc ) ).to.equal(
  57. '<blockQuote><listItem alignment="center" indent="0" type="numbered">Foo[]</listItem></blockQuote>'
  58. );
  59. } );
  60. } );
  61. } );