@@ -7,7 +7,6 @@ import buildViewConverter from '../../src/conversion/buildviewconverter';
77
88import ModelSchema from '../../src/model/schema' ;
99import ModelDocumentFragment from '../../src/model/documentfragment' ;
10- import ModelDocument from '../../src/model/document' ;
1110import ModelElement from '../../src/model/element' ;
1211import ModelTextProxy from '../../src/model/textproxy' ;
1312import ModelRange from '../../src/model/range' ;
@@ -64,7 +63,7 @@ const textAttributes = [ undefined, 'linkHref', 'linkTitle', 'bold', 'italic', '
6463const pAttributes = [ undefined , 'class' , 'important' , 'theme' , 'decorated' , 'size' ] ;
6564
6665describe ( 'View converter builder' , ( ) => {
67- let dispatcher , modelDoc , modelRoot , schema , objWithContext ;
66+ let dispatcher , schema , objWithContext ;
6867
6968 beforeEach ( ( ) => {
7069 // `additionalData` parameter for `.convert` calls.
@@ -91,16 +90,12 @@ describe( 'View converter builder', () => {
9190
9291 dispatcher = new ViewConversionDispatcher ( { schema } ) ;
9392 dispatcher . on ( 'text' , convertText ( ) ) ;
94-
95- modelDoc = new ModelDocument ( ) ;
96- modelRoot = modelDoc . createRoot ( ) ;
9793 } ) ;
9894
9995 it ( 'should convert from view element to model element' , ( ) => {
10096 buildViewConverter ( ) . for ( dispatcher ) . fromElement ( 'p' ) . toElement ( 'paragraph' ) ;
10197
10298 const conversionResult = dispatcher . convert ( new ViewContainerElement ( 'p' , null , new ViewText ( 'foo' ) ) , objWithContext ) ;
103- modelRoot . appendChildren ( conversionResult ) ;
10499
105100 expect ( modelToString ( conversionResult ) ) . to . equal ( '<paragraph>foo</paragraph>' ) ;
106101 } ) ;
@@ -111,7 +106,6 @@ describe( 'View converter builder', () => {
111106 . toElement ( viewElement => new ModelElement ( 'image' , { src : viewElement . getAttribute ( 'src' ) } ) ) ;
112107
113108 const conversionResult = dispatcher . convert ( new ViewContainerElement ( 'img' , { src : 'foo.jpg' } ) , objWithContext ) ;
114- modelRoot . appendChildren ( conversionResult ) ;
115109
116110 expect ( modelToString ( conversionResult ) ) . to . equal ( '<image src="foo.jpg"></image>' ) ;
117111 } ) ;
@@ -122,10 +116,9 @@ describe( 'View converter builder', () => {
122116 const conversionResult = dispatcher . convert (
123117 new ViewAttributeElement ( 'strong' , null , new ViewText ( 'foo' ) ) , objWithContext
124118 ) ;
125- modelRoot . appendChildren ( conversionResult ) ;
126119
127120 // Have to check root because result is a ModelText.
128- expect ( modelToString ( modelRoot ) ) . to . equal ( '<$root><$ text bold="true">foo</$text></$root >' ) ;
121+ expect ( modelToString ( conversionResult ) ) . to . equal ( '<$text bold="true">foo</$text>' ) ;
129122 } ) ;
130123
131124 it ( 'should convert from view element to model attributes using creator function' , ( ) => {
@@ -136,10 +129,9 @@ describe( 'View converter builder', () => {
136129 const conversionResult = dispatcher . convert (
137130 new ViewAttributeElement ( 'a' , { href : 'foo.html' } , new ViewText ( 'foo' ) ) , objWithContext
138131 ) ;
139- modelRoot . appendChildren ( conversionResult ) ;
140132
141133 // Have to check root because result is a ModelText.
142- expect ( modelToString ( modelRoot ) ) . to . equal ( '<$root><$ text linkHref="foo.html">foo</$text></$root >' ) ;
134+ expect ( modelToString ( conversionResult ) ) . to . equal ( '<$text linkHref="foo.html">foo</$text>' ) ;
143135 } ) ;
144136
145137 it ( 'should convert from view attribute to model attribute' , ( ) => {
@@ -152,7 +144,6 @@ describe( 'View converter builder', () => {
152144 const conversionResult = dispatcher . convert (
153145 new ViewContainerElement ( 'p' , { class : 'myClass' } , new ViewText ( 'foo' ) ) , objWithContext
154146 ) ;
155- modelRoot . appendChildren ( conversionResult ) ;
156147
157148 expect ( modelToString ( conversionResult ) ) . to . equal ( '<paragraph class="myClass">foo</paragraph>' ) ;
158149 } ) ;
@@ -200,7 +191,6 @@ describe( 'View converter builder', () => {
200191 ] ) ;
201192
202193 const conversionResult = dispatcher . convert ( viewElement , objWithContext ) ;
203- modelRoot . appendChildren ( conversionResult ) ;
204194
205195 expect ( modelToString ( conversionResult ) ) . to . equal ( '<paragraph><$text bold="true">aaabbbcccddd</$text></paragraph>' ) ;
206196 } ) ;
@@ -337,7 +327,7 @@ describe( 'View converter builder', () => {
337327 result = dispatcher . convert (
338328 new ViewContainerElement ( 'span' , { class : 'megatron' } , new ViewText ( 'foo' ) ) , objWithContext
339329 ) ;
340- modelRoot . appendChildren ( result ) ;
330+
341331 expect ( modelToString ( result ) ) . to . equal ( '<span>foo</span>' ) ;
342332
343333 // Almost a megatron. Missing a head.
@@ -346,7 +336,6 @@ describe( 'View converter builder', () => {
346336 objWithContext
347337 ) ;
348338
349- modelRoot . appendChildren ( result ) ;
350339 expect ( modelToString ( result ) ) . to . equal ( '<span>foo</span>' ) ;
351340
352341 // This would be a megatron but is a paragraph.
@@ -359,7 +348,6 @@ describe( 'View converter builder', () => {
359348 objWithContext
360349 ) ;
361350
362- modelRoot . appendChildren ( result ) ;
363351 expect ( modelToString ( result ) ) . to . equal ( '<paragraph>foo</paragraph>' ) ;
364352
365353 // At last we have a megatron!
@@ -372,7 +360,6 @@ describe( 'View converter builder', () => {
372360 objWithContext
373361 ) ;
374362
375- modelRoot . appendChildren ( result ) ;
376363 expect ( modelToString ( result ) ) . to . equal ( '<MEGATRON>foo</MEGATRON>' ) ;
377364 } ) ;
378365
@@ -392,7 +379,6 @@ describe( 'View converter builder', () => {
392379
393380 const conversionResult = dispatcher . convert ( viewElement , objWithContext ) ;
394381
395- modelRoot . appendChildren ( conversionResult ) ;
396382 expect ( modelToString ( conversionResult ) ) . to . equal ( '<span transformer="megatron">foo</span>' ) ;
397383 } ) ;
398384
@@ -415,7 +401,6 @@ describe( 'View converter builder', () => {
415401 const conversionResult = dispatcher . convert (
416402 new ViewContainerElement ( 'p' , { class : 'myClass' } , new ViewText ( 'foo' ) ) , objWithContext
417403 ) ;
418- modelRoot . appendChildren ( conversionResult ) ;
419404
420405 // Element converter was fired first even though attribute converter was added first.
421406 expect ( modelToString ( conversionResult ) ) . to . equal ( '<paragraph class="myClass">foo</paragraph>' ) ;
@@ -432,7 +417,7 @@ describe( 'View converter builder', () => {
432417 result = dispatcher . convert (
433418 new ViewContainerElement ( 'p' , { class : 'myClass' } , new ViewText ( 'foo' ) ) , objWithContext
434419 ) ;
435- modelRoot . appendChildren ( result ) ;
420+
436421 expect ( modelToString ( result ) ) . to . equal ( '<paragraph class="myClass">foo</paragraph>' ) ;
437422
438423 buildViewConverter ( ) . for ( dispatcher )
@@ -442,7 +427,7 @@ describe( 'View converter builder', () => {
442427 result = dispatcher . convert (
443428 new ViewContainerElement ( 'p' , { class : 'myClass' } , new ViewText ( 'foo' ) ) , objWithContext
444429 ) ;
445- modelRoot . appendChildren ( result ) ;
430+
446431 expect ( modelToString ( result ) ) . to . equal ( '<customP>foo</customP>' ) ;
447432 } ) ;
448433
@@ -461,9 +446,7 @@ describe( 'View converter builder', () => {
461446 . toAttribute ( 'size' , 'small' ) ;
462447
463448 const viewElement = new ViewContainerElement ( 'p' , { class : 'decorated small' } , new ViewText ( 'foo' ) ) ;
464-
465449 const conversionResult = dispatcher . convert ( viewElement , objWithContext ) ;
466- modelRoot . appendChildren ( conversionResult ) ;
467450
468451 // P element and it's children got converted by the converter (1) and the converter (1) got fired
469452 // because P name was not consumed in converter (2). Converter (3) could consume class="small" because
@@ -487,7 +470,6 @@ describe( 'View converter builder', () => {
487470 ] ) ;
488471
489472 const conversionResult = dispatcher . convert ( viewStructure , objWithContext ) ;
490- modelRoot . appendChildren ( conversionResult ) ;
491473
492474 expect ( modelToString ( conversionResult ) ) . to . equal ( '<div class="myClass"><abcd>foo</abcd></div>' ) ;
493475 } ) ;
0 commit comments