blockquoteengine.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import BlockQuoteEngine from '../src/blockquoteengine';
  6. import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
  7. import ListEngine from '@ckeditor/ckeditor5-list/src/listengine';
  8. import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
  9. import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
  10. import BlockQuoteCommand from '../src/blockquotecommand';
  11. describe( 'BlockQuoteEngine', () => {
  12. let editor, doc;
  13. beforeEach( () => {
  14. return VirtualTestEditor.create( {
  15. plugins: [ BlockQuoteEngine, Paragraph ]
  16. } )
  17. .then( newEditor => {
  18. editor = newEditor;
  19. doc = editor.document;
  20. } );
  21. } );
  22. afterEach( () => {
  23. editor.destroy();
  24. } );
  25. it( 'adds a blockQuote command', () => {
  26. expect( editor.commands.get( 'blockQuote' ) ).to.be.instanceOf( BlockQuoteCommand );
  27. } );
  28. it( 'allows for blockQuote in the $root', () => {
  29. expect( doc.schema.check( { name: 'blockQuote', inside: '$root' } ) ).to.be.true;
  30. } );
  31. it( 'allows for $block in blockQuote', () => {
  32. expect( doc.schema.check( { name: '$block', inside: 'blockQuote' } ) ).to.be.true;
  33. expect( doc.schema.check( { name: 'paragraph', inside: 'blockQuote' } ) ).to.be.true;
  34. } );
  35. it( 'adds converters to the data pipeline', () => {
  36. const data = '<blockquote><p>x</p></blockquote>';
  37. editor.setData( data );
  38. expect( getModelData( doc ) ).to.equal( '<blockQuote><paragraph>[]x</paragraph></blockQuote>' );
  39. expect( editor.getData() ).to.equal( data );
  40. } );
  41. it( 'adds a converter to the view pipeline', () => {
  42. setModelData( doc, '<blockQuote><paragraph>x</paragraph></blockQuote>' );
  43. expect( editor.getData() ).to.equal( '<blockquote><p>x</p></blockquote>' );
  44. } );
  45. it( 'allows list items inside blockQuote', () => {
  46. return VirtualTestEditor.create( {
  47. plugins: [ BlockQuoteEngine, Paragraph, ListEngine ]
  48. } )
  49. .then( editor => {
  50. editor.setData( '<blockquote><ul><li>xx</li></ul></blockquote>' );
  51. expect( editor.getData() ).to.equal( '<blockquote><ul><li>xx</li></ul></blockquote>' );
  52. } );
  53. } );
  54. } );