8
0

formatsengine.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. 'use strict';
  6. import FormatsEngine from '/ckeditor5/formats/formatsengine.js';
  7. import Paragraph from '/ckeditor5/paragraph/paragraph.js';
  8. import Editor from '/ckeditor5/editor.js';
  9. import StandardCreator from '/ckeditor5/creator/standardcreator.js';
  10. import { getData } from '/tests/engine/_utils/model.js';
  11. describe( 'FormatsEngine', () => {
  12. let editor, document;
  13. beforeEach( () => {
  14. editor = new Editor( null, {
  15. creator: StandardCreator,
  16. features: [ FormatsEngine ]
  17. } );
  18. return editor.init().then( () => {
  19. document = editor.document;
  20. document.createRoot( 'main' );
  21. } );
  22. } );
  23. it( 'should be loaded', () => {
  24. expect( editor.plugins.get( FormatsEngine ) ).to.be.instanceOf( FormatsEngine );
  25. } );
  26. it( 'should load paragraph feature', () => {
  27. expect( editor.plugins.get( Paragraph ) ).to.be.instanceOf( Paragraph );
  28. } );
  29. it( 'should set proper schema rules', () => {
  30. expect( document.schema.hasItem( 'heading1' ) ).to.be.true;
  31. expect( document.schema.hasItem( 'heading2' ) ).to.be.true;
  32. expect( document.schema.hasItem( 'heading3' ) ).to.be.true;
  33. expect( document.schema.check( { name: 'heading1', inside: '$root' } ) ).to.be.true;
  34. expect( document.schema.check( { name: '$inline', inside: 'heading1' } ) ).to.be.true;
  35. expect( document.schema.check( { name: 'heading2', inside: '$root' } ) ).to.be.true;
  36. expect( document.schema.check( { name: '$inline', inside: 'heading2' } ) ).to.be.true;
  37. expect( document.schema.check( { name: 'heading3', inside: '$root' } ) ).to.be.true;
  38. expect( document.schema.check( { name: '$inline', inside: 'heading3' } ) ).to.be.true;
  39. } );
  40. // it( 'should convert heading1', () => {
  41. // editor.setData( '<h2>foobar</h2>' );
  42. //
  43. // expect( getData( document, { withoutSelection: true } ) ).to.equal( '<heading1>foobar</heading1>' );
  44. // expect( editor.getData() ).to.equal( '<h2>foobar</h2>' );
  45. // } );
  46. // it( 'should convert heading2', () => {
  47. // editor.setData( '<h3>foobar</h3>' );
  48. //
  49. // expect( getData( document, { withoutSelection: true } ) ).to.equal( '<heading2>foobar</heading2>' );
  50. // expect( editor.getData() ).to.equal( '<h3>foobar</h3>' );
  51. // } );
  52. //
  53. // it( 'should convert heading3', () => {
  54. // editor.setData( '<h4>foobar</h4>' );
  55. //
  56. // expect( getData( document, { withoutSelection: true } ) ).to.equal( '<heading3>foobar</heading3>' );
  57. // expect( editor.getData() ).to.equal( '<h4>foobar</h4>' );
  58. // } );
  59. } );