@@ -56,25 +56,36 @@ describe( 'ImageStyleEngine', () => {
5656 editor . setData ( '<figure class="image side-class"><img src="foo.png" /></figure>' ) ;
5757
5858 expect ( getModelData ( document , { withoutSelection : true } ) ) . to . equal ( '<image imageStyle="side" src="foo.png"></image>' ) ;
59+ expect ( getViewData ( viewDocument , { withoutSelection : true } ) ) . to . equal (
60+ '<figure class="image ck-widget side-class" contenteditable="false">' +
61+ '<img src="foo.png"></img>' +
62+ '</figure>' ) ;
5963 } ) ;
6064
6165 it ( 'should not convert from view to model if class is not defined' , ( ) => {
6266 editor . setData ( '<figure class="image foo-bar"><img src="foo.png" /></figure>' ) ;
6367
6468 expect ( getModelData ( document , { withoutSelection : true } ) ) . to . equal ( '<image src="foo.png"></image>' ) ;
69+ expect ( getViewData ( viewDocument , { withoutSelection : true } ) ) . to . equal (
70+ '<figure class="image ck-widget" contenteditable="false"><img src="foo.png"></img></figure>'
71+ ) ;
6572 } ) ;
6673
6774 it ( 'should not convert from view to model when not in image figure' , ( ) => {
6875 editor . setData ( '<figure class="side-class"></figure>' ) ;
6976
7077 expect ( getModelData ( document , { withoutSelection : true } ) ) . to . equal ( '' ) ;
78+ expect ( getViewData ( viewDocument , { withoutSelection : true } ) ) . to . equal ( '' ) ;
7179 } ) ;
7280
7381 it ( 'should not convert from view to model if schema prevents it' , ( ) => {
7482 document . schema . disallow ( { name : 'image' , attributes : 'imageStyle' } ) ;
7583 editor . setData ( '<figure class="image side-class"><img src="foo.png" /></figure>' ) ;
7684
7785 expect ( getModelData ( document , { withoutSelection : true } ) ) . to . equal ( '<image src="foo.png"></image>' ) ;
86+ expect ( getViewData ( viewDocument , { withoutSelection : true } ) ) . to . equal (
87+ '<figure class="image ck-widget" contenteditable="false"><img src="foo.png"></img></figure>'
88+ ) ;
7889 } ) ;
7990
8091 it ( 'should convert model to view: adding attribute' , ( ) => {
@@ -87,6 +98,9 @@ describe( 'ImageStyleEngine', () => {
8798 } ) ;
8899
89100 expect ( editor . getData ( ) ) . to . equal ( '<figure class="image side-class"><img src="foo.png"></figure>' ) ;
101+ expect ( getViewData ( viewDocument , { withoutSelection : true } ) ) . to . equal (
102+ '<figure class="image ck-widget side-class" contenteditable="false"><img src="foo.png"></img></figure>'
103+ ) ;
90104 } ) ;
91105
92106 it ( 'should convert model to view: removing attribute' , ( ) => {
@@ -99,6 +113,9 @@ describe( 'ImageStyleEngine', () => {
99113 } ) ;
100114
101115 expect ( editor . getData ( ) ) . to . equal ( '<figure class="image"><img src="foo.png"></figure>' ) ;
116+ expect ( getViewData ( viewDocument , { withoutSelection : true } ) ) . to . equal (
117+ '<figure class="image ck-widget" contenteditable="false"><img src="foo.png"></img></figure>'
118+ ) ;
102119 } ) ;
103120
104121 it ( 'should convert model to view: change attribute' , ( ) => {
@@ -111,6 +128,22 @@ describe( 'ImageStyleEngine', () => {
111128 } ) ;
112129
113130 expect ( editor . getData ( ) ) . to . equal ( '<figure class="image side-class"><img src="foo.png"></figure>' ) ;
131+
132+ // https://github.com/ckeditor/ckeditor5-image/issues/132
133+ expect ( getViewData ( viewDocument , { withoutSelection : true } ) ) . to . equal (
134+ '<figure class="image ck-widget side-class" contenteditable="false"><img src="foo.png"></img></figure>'
135+ ) ;
136+
137+ document . enqueueChanges ( ( ) => {
138+ batch . setAttribute ( image , 'imageStyle' , 'dummy' ) ;
139+ } ) ;
140+
141+ expect ( editor . getData ( ) ) . to . equal ( '<figure class="image dummy-class"><img src="foo.png"></figure>' ) ;
142+
143+ // https://github.com/ckeditor/ckeditor5-image/issues/132
144+ expect ( getViewData ( viewDocument , { withoutSelection : true } ) ) . to . equal (
145+ '<figure class="image ck-widget dummy-class" contenteditable="false"><img src="foo.png"></img></figure>'
146+ ) ;
114147 } ) ;
115148
116149 it ( 'should not convert from model to view if already consumed: adding attribute' , ( ) => {
@@ -177,6 +210,9 @@ describe( 'ImageStyleEngine', () => {
177210 } ) ;
178211
179212 expect ( editor . getData ( ) ) . to . equal ( '<figure class="image"><img src="foo.png"></figure>' ) ;
213+ expect ( getViewData ( viewDocument , { withoutSelection : true } ) ) . to . equal (
214+ '<figure class="image ck-widget" contenteditable="false"><img src="foo.png"></img></figure>'
215+ ) ;
180216 } ) ;
181217
182218 it ( 'should not convert from model to view if style is not present: change attribute' , ( ) => {
@@ -189,6 +225,9 @@ describe( 'ImageStyleEngine', () => {
189225 } ) ;
190226
191227 expect ( editor . getData ( ) ) . to . equal ( '<figure class="image"><img src="foo.png"></figure>' ) ;
228+ expect ( getViewData ( viewDocument , { withoutSelection : true } ) ) . to . equal (
229+ '<figure class="image ck-widget" contenteditable="false"><img src="foo.png"></img></figure>'
230+ ) ;
192231 } ) ;
193232
194233 it ( 'should not convert from model to view if style is not present: remove attribute' , ( ) => {
@@ -201,5 +240,8 @@ describe( 'ImageStyleEngine', () => {
201240 } ) ;
202241
203242 expect ( editor . getData ( ) ) . to . equal ( '<figure class="image"><img src="foo.png"></figure>' ) ;
243+ expect ( getViewData ( viewDocument , { withoutSelection : true } ) ) . to . equal (
244+ '<figure class="image ck-widget" contenteditable="false"><img src="foo.png"></img></figure>'
245+ ) ;
204246 } ) ;
205247} ) ;
0 commit comments