/** * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md. */ /* bender-tags: treeview */ 'use strict'; import Writer from '/ckeditor5/core/treeview/writer.js'; import Element from '/ckeditor5/core/treeview/element.js'; import Text from '/ckeditor5/core/treeview/text.js'; import utils from '/tests/core/treeview/writer/_utils/utils.js'; describe( 'Writer', () => { const create = utils.create; const test = utils.test; let writer; beforeEach( () => { writer = new Writer(); } ); describe( 'breakAttributes', () => { //
{|foobar}
->|{foobar}
it( '{|foobar}
', () => { const created = create( writer, { instanceOf: Element, name: 'p', children: [ { instanceOf: Text, data: 'foobar', position: 0 } ] } ); const newPosition = writer.breakAttributes( created.position ); test( writer, newPosition, created.node, { instanceOf: Element, name: 'p', position: 0, children: [ { instanceOf: Text, data: 'foobar' } ] } ); } ); it( 'foo|bar
', () => { //{foo|bar}
->{foo}|{bar}
const created = create( writer, { instanceOf: Element, name: 'p', children: [ { instanceOf: Text, data: 'foobar', position: 3 } ] } ); const newPosition = writer.breakAttributes( created.position ); test( writer, newPosition, created.node, { instanceOf: Element, name: 'p', position: 1, children: [ { instanceOf: Text, data: 'foo' }, { instanceOf: Text, data: 'bar' } ] } ); } ); it( '{foobar|}
', () => { //{foobar|}
->{foobar}|
const created = create( writer, { instanceOf: Element, name: 'p', children: [ { instanceOf: Text, data: 'foobar', position: 6 } ] } ); const newPosition = writer.breakAttributes( created.position ); test( writer, newPosition, created.node, { instanceOf: Element, name: 'p', position: 1, children: [ { instanceOf: Text, data: 'foobar' } ] } ); } ); it( '{foo|bar}
', () => { //{foo|bar}
->{foo}|{bar}
const created = create( writer, { instanceOf: Element, name: 'p', children: [ { instanceOf: Element, name: 'b', priority: 1, children: [ { instanceOf: Text, data: 'foobar', position: 3 } ] } ] } ); const newPosition = writer.breakAttributes( created.position ); test( writer, newPosition, created.node, { instanceOf: Element, name: 'p', position: 1, children: [ { instanceOf: Element, name: 'b', priority: 1, children: [ { instanceOf: Text, data: 'foo' } ] }, { instanceOf: Element, name: 'b', priority: 1, children: [ { instanceOf: Text, data: 'bar' } ] } ] } ); } ); it( '{|foobar}
', () => { //{|foobar}
->|{foobar}
const created = create( writer, { instanceOf: Element, name: 'p', children: [ { instanceOf: Element, name: 'b', priority: 1, children: [ { instanceOf: Element, name: 'u', priority: 1, children: [ { instanceOf: Text, data: 'foobar', position: 0 } ] } ] } ] } ); const newPosition = writer.breakAttributes( created.position ); test( writer, newPosition, created.node, { instanceOf: Element, name: 'p', position: 0, children: [ { instanceOf: Element, name: 'b', priority: 1, children: [ { instanceOf: Element, name: 'u', priority: 1, children: [ { instanceOf: Text, data: 'foobar' } ] } ] } ] } ); } ); //{foo|ba}r
->{foo}|{bar}
it( '{foo|bar}
', () => { const created = create( writer, { instanceOf: Element, name: 'p', children: [ { instanceOf: Element, name: 'b', priority: 1, children: [ { instanceOf: Element, name: 'u', priority: 1, children: [ { instanceOf: Text, data: 'foobar', position: 3 } ] } ] } ] } ); const newPosition = writer.breakAttributes( created.position ); test( writer, newPosition, created.node, { instanceOf: Element, name: 'p', position: 1, children: [ { instanceOf: Element, name: 'b', priority: 1, children: [ { instanceOf: Element, name: 'u', priority: 1, children: [ { instanceOf: Text, data: 'foo' } ] } ] }, { instanceOf: Element, name: 'b', priority: 1, children: [ { instanceOf: Element, name: 'u', priority: 1, children: [ { instanceOf: Text, data: 'bar' } ] } ] } ] } ); } ); it( '{foobar|}
', () => { //{foobar|}
->{foobar}|
const created = create( writer, { instanceOf: Element, name: 'p', children: [ { instanceOf: Element, name: 'b', priority: 1, children: [ { instanceOf: Element, name: 'u', priority: 1, children: [ { instanceOf: Text, data: 'foobar', position: 6 } ] } ] } ] } ); const newPosition = writer.breakAttributes( created.position ); test( writer, newPosition, created.node, { instanceOf: Element, name: 'p', position: 1, children: [ { instanceOf: Element, name: 'b', priority: 1, children: [ { instanceOf: Element, name: 'u', priority: 1, children: [ { instanceOf: Text, data: 'foobar' } ] } ] } ] } ); } ); } ); } );