8
0

blockquoteengine.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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, model;
  13. beforeEach( () => {
  14. return VirtualTestEditor
  15. .create( {
  16. plugins: [ BlockQuoteEngine, Paragraph ]
  17. } )
  18. .then( newEditor => {
  19. editor = newEditor;
  20. model = editor.model;
  21. } );
  22. } );
  23. afterEach( () => {
  24. return editor.destroy();
  25. } );
  26. it( 'adds a blockQuote command', () => {
  27. expect( editor.commands.get( 'blockQuote' ) ).to.be.instanceOf( BlockQuoteCommand );
  28. } );
  29. it( 'allows for blockQuote in the $root', () => {
  30. expect( model.schema.check( { name: 'blockQuote', inside: '$root' } ) ).to.be.true;
  31. } );
  32. it( 'allows for $block in blockQuote', () => {
  33. expect( model.schema.check( { name: '$block', inside: 'blockQuote' } ) ).to.be.true;
  34. expect( model.schema.check( { name: 'paragraph', inside: 'blockQuote' } ) ).to.be.true;
  35. } );
  36. it( 'adds converters to the data pipeline', () => {
  37. const data = '<blockquote><p>x</p></blockquote>';
  38. editor.setData( data );
  39. expect( getModelData( model ) ).to.equal( '<blockQuote><paragraph>[]x</paragraph></blockQuote>' );
  40. expect( editor.getData() ).to.equal( data );
  41. } );
  42. it( 'adds a converter to the view pipeline', () => {
  43. setModelData( model, '<blockQuote><paragraph>x</paragraph></blockQuote>' );
  44. expect( editor.getData() ).to.equal( '<blockquote><p>x</p></blockquote>' );
  45. } );
  46. it( 'allows list items inside blockQuote', () => {
  47. return VirtualTestEditor
  48. .create( {
  49. plugins: [ BlockQuoteEngine, Paragraph, ListEngine ]
  50. } )
  51. .then( editor => {
  52. editor.setData( '<blockquote><ul><li>xx</li></ul></blockquote>' );
  53. expect( editor.getData() ).to.equal( '<blockquote><ul><li>xx</li></ul></blockquote>' );
  54. } );
  55. } );
  56. } );