virtualtesteditor.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 Editor from '/ckeditor5/editor/editor.js';
  7. import VirtualTestEditor from '/tests/ckeditor5/_utils/virtualtesteditor.js';
  8. import VirtualEditingController from '/tests/ckeditor5/_utils/virtualeditingcontroller.js';
  9. import HtmlDataProcessor from '/ckeditor5/engine/dataprocessor/htmldataprocessor.js';
  10. import { getData, setData } from '/tests/engine/_utils/model.js';
  11. describe( 'VirtualTestEditor', () => {
  12. describe( 'constructor', () => {
  13. it( 'creates an instance of editor', () => {
  14. const editor = new VirtualTestEditor( { foo: 1 } );
  15. expect( editor ).to.be.instanceof( Editor );
  16. } );
  17. it( 'sets necessary properties', () => {
  18. const editor = new VirtualTestEditor( { foo: 1 } );
  19. expect( editor.config.get( 'foo' ) ).to.equal( 1 );
  20. expect( editor.editing ).to.be.instanceof( VirtualEditingController );
  21. expect( editor.data.processor ).to.be.instanceof( HtmlDataProcessor );
  22. } );
  23. } );
  24. describe( 'setData', () => {
  25. let editor;
  26. beforeEach( () => {
  27. editor = new VirtualTestEditor();
  28. editor.document.schema.allow( { name: '$text', inside: '$root' } );
  29. } );
  30. it( 'should set data', () => {
  31. editor.document.createRoot();
  32. editor.setData( 'foo' );
  33. expect( getData( editor.document, { rootName: 'main', withoutSelection: true } ) ).to.equal( 'foo' );
  34. } );
  35. } );
  36. describe( 'getData', () => {
  37. let editor;
  38. beforeEach( () => {
  39. editor = new VirtualTestEditor();
  40. editor.document.schema.allow( { name: '$text', inside: '$root' } );
  41. } );
  42. it( 'should get data', () => {
  43. editor.document.createRoot();
  44. setData( editor.document, 'foo' );
  45. expect( editor.getData() ).to.equal( 'foo' );
  46. } );
  47. } );
  48. } );