| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- /**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
- import Editor from '/ckeditor5/editor/editor.js';
- import ModelTestEditor from '/tests/ckeditor5/_utils/modeltesteditor.js';
- import HtmlDataProcessor from '/ckeditor5/engine/dataprocessor/htmldataprocessor.js';
- import { getData, setData } from '/tests/engine/_utils/model.js';
- import testUtils from '/tests/ckeditor5/_utils/utils.js';
- testUtils.createSinonSandbox();
- describe( 'ModelTestEditor', () => {
- describe( 'constructor', () => {
- it( 'creates an instance of editor', () => {
- const editor = new ModelTestEditor( { foo: 1 } );
- expect( editor ).to.be.instanceof( Editor );
- expect( editor.config.get( 'foo' ) ).to.equal( 1 );
- } );
- it( 'creates model and view roots', () => {
- const editor = new ModelTestEditor( { foo: 1 } );
- expect( editor.document.getRoot() ).to.have.property( 'name', '$root' );
- expect( editor.data.processor ).to.be.instanceof( HtmlDataProcessor );
- } );
- } );
- describe( 'create', () => {
- it( 'creates an instance of editor', () => {
- return ModelTestEditor.create( { foo: 1 } )
- .then( editor => {
- expect( editor ).to.be.instanceof( ModelTestEditor );
- expect( editor.config.get( 'foo' ) ).to.equal( 1 );
- } );
- } );
- } );
- describe( 'setData', () => {
- let editor;
- beforeEach( () => {
- return ModelTestEditor.create()
- .then( newEditor => {
- editor = newEditor;
- editor.document.schema.allow( { name: '$text', inside: '$root' } );
- } );
- } );
- it( 'should set data of the first root', () => {
- editor.document.createRoot( '$root', 'secondRoot' );
- editor.setData( 'foo' );
- expect( getData( editor.document, { rootName: 'main', withoutSelection: true } ) ).to.equal( 'foo' );
- } );
- } );
- describe( 'getData', () => {
- let editor;
- beforeEach( () => {
- return ModelTestEditor.create()
- .then( newEditor => {
- editor = newEditor;
- editor.document.schema.allow( { name: '$text', inside: '$root' } );
- } );
- } );
- it( 'should set data of the first root', () => {
- setData( editor.document, 'foo' );
- expect( editor.getData() ).to.equal( 'foo' );
- } );
- } );
- } );
|