@@ -83,6 +83,23 @@ describe( 'InlineEditor', () => {
83
83
expect ( editor . editing . view . getDomRoot ( ) ) . to . equal ( editor . ui . element ) ;
84
84
} ) ;
85
85
} ) ;
86
+
87
+ // See: https://github.com/ckeditor/ckeditor5/issues/746
88
+ it ( 'should throw when trying to create the editor using the same source element more than once' , done => {
89
+ InlineEditor . create ( editorElement )
90
+ . then (
91
+ ( ) => {
92
+ expect . fail ( 'Inline editor should not initialize on an element already used by other instance.' ) ;
93
+ } ,
94
+ err => {
95
+ assertCKEditorError ( err ,
96
+ / ^ e d i t o r - s o u r c e - e l e m e n t - a l r e a d y - u s e d /
97
+ ) ;
98
+ }
99
+ )
100
+ . then ( done )
101
+ . catch ( done ) ;
102
+ } ) ;
86
103
} ) ;
87
104
88
105
describe ( 'create()' , ( ) => {
@@ -117,6 +134,9 @@ describe( 'InlineEditor', () => {
117
134
} ) ;
118
135
119
136
it ( 'should not require config object' , ( ) => {
137
+ const editorElement = document . createElement ( 'div' ) ;
138
+ editorElement . innerHTML = '<p><strong>foo</strong> bar</p>' ;
139
+
120
140
// Just being safe with `builtinPlugins` static property.
121
141
class CustomInlineEditor extends InlineEditor { }
122
142
CustomInlineEditor . builtinPlugins = [ Paragraph , Bold ] ;
@@ -126,6 +146,9 @@ describe( 'InlineEditor', () => {
126
146
expect ( newEditor . getData ( ) ) . to . equal ( '<p><strong>foo</strong> bar</p>' ) ;
127
147
128
148
return newEditor . destroy ( ) ;
149
+ } )
150
+ . then ( ( ) => {
151
+ editorElement . remove ( ) ;
129
152
} ) ;
130
153
} ) ;
131
154
@@ -140,13 +163,18 @@ describe( 'InlineEditor', () => {
140
163
} ) ;
141
164
142
165
it ( 'initializes with config.initialData' , ( ) => {
166
+ const editorElement = document . createElement ( 'div' ) ;
167
+ editorElement . innerHTML = '<p>Hello world!</p>' ;
168
+
143
169
return InlineEditor . create ( editorElement , {
144
170
initialData : '<p>Hello world!</p>' ,
145
171
plugins : [ Paragraph ]
146
172
} ) . then ( editor => {
147
173
expect ( editor . getData ( ) ) . to . equal ( '<p>Hello world!</p>' ) ;
148
174
149
- editor . destroy ( ) ;
175
+ return editor . destroy ( ) ;
176
+ } ) . then ( ( ) => {
177
+ editorElement . remove ( ) ;
150
178
} ) ;
151
179
} ) ;
152
180
0 commit comments