@@ -30,6 +30,8 @@ describe( 'CKEditor Component', () => {
30
30
} ) ;
31
31
32
32
it ( 'calls editor#create when initializing' , done => {
33
+ Vue . config . errorHandler = done ;
34
+
33
35
const stub = sandbox . stub ( MockEditor , 'create' ) . resolves ( new MockEditor ( ) ) ;
34
36
const { wrapper } = createComponent ( ) ;
35
37
@@ -42,6 +44,8 @@ describe( 'CKEditor Component', () => {
42
44
} ) ;
43
45
44
46
it ( 'calls editor#destroy when destroying' , done => {
47
+ Vue . config . errorHandler = done ;
48
+
45
49
const stub = sandbox . stub ( MockEditor . prototype , 'destroy' ) . resolves ( ) ;
46
50
const { wrapper, vm } = createComponent ( ) ;
47
51
@@ -55,6 +59,8 @@ describe( 'CKEditor Component', () => {
55
59
} ) ;
56
60
57
61
it ( 'passes editor promise rejection error to console.error' , done => {
62
+ Vue . config . errorHandler = done ;
63
+
58
64
const error = new Error ( 'Something went wrong.' ) ;
59
65
const consoleErrorStub = sandbox . stub ( console , 'error' ) ;
60
66
@@ -75,6 +81,8 @@ describe( 'CKEditor Component', () => {
75
81
describe ( 'properties' , ( ) => {
76
82
it ( '#editor' , ( ) => {
77
83
it ( 'accepts a string' , done => {
84
+ Vue . config . errorHandler = done ;
85
+
78
86
expect ( vm . editor ) . to . equal ( 'classic' ) ;
79
87
80
88
Vue . nextTick ( ( ) => {
@@ -85,6 +93,8 @@ describe( 'CKEditor Component', () => {
85
93
} ) ;
86
94
87
95
it ( 'accepts an editor constructor' , done => {
96
+ Vue . config . errorHandler = done ;
97
+
88
98
const { wrapper, vm } = createComponent ( {
89
99
editor : MockEditor
90
100
} ) ;
@@ -105,6 +115,8 @@ describe( 'CKEditor Component', () => {
105
115
} ) ;
106
116
107
117
it ( 'should set the initial data' , done => {
118
+ Vue . config . errorHandler = done ;
119
+
108
120
const setDataStub = sandbox . stub ( MockEditor . prototype , 'setData' ) ;
109
121
const { wrapper } = createComponent ( {
110
122
value : 'foo'
@@ -141,6 +153,8 @@ describe( 'CKEditor Component', () => {
141
153
} ) ;
142
154
143
155
it ( 'should set the initial editor#isReadOnly' , done => {
156
+ Vue . config . errorHandler = done ;
157
+
144
158
const { wrapper, vm } = createComponent ( {
145
159
disabled : true
146
160
} ) ;
@@ -159,6 +173,8 @@ describe( 'CKEditor Component', () => {
159
173
} ) ;
160
174
161
175
it ( 'should set the initial editor#config' , done => {
176
+ Vue . config . errorHandler = done ;
177
+
162
178
const { wrapper, vm } = createComponent ( {
163
179
config : { foo : 'bar' }
164
180
} ) ;
@@ -172,6 +188,8 @@ describe( 'CKEditor Component', () => {
172
188
} ) ;
173
189
174
190
it ( '#instance should be defined' , done => {
191
+ Vue . config . errorHandler = done ;
192
+
175
193
Vue . nextTick ( ( ) => {
176
194
expect ( vm . instance ) . to . be . instanceOf ( MockEditor ) ;
177
195
@@ -182,6 +200,8 @@ describe( 'CKEditor Component', () => {
182
200
183
201
describe ( 'bindings' , ( ) => {
184
202
it ( '#disabled should control editor#isReadOnly' , done => {
203
+ Vue . config . errorHandler = done ;
204
+
185
205
const { wrapper, vm } = createComponent ( {
186
206
disabled : true
187
207
} ) ;
@@ -198,18 +218,22 @@ describe( 'CKEditor Component', () => {
198
218
} ) ;
199
219
200
220
it ( '#value should trigger editor#setData' , done => {
221
+ Vue . config . errorHandler = done ;
222
+
201
223
Vue . nextTick ( ( ) => {
202
224
const spy = sandbox . spy ( vm . instance , 'setData' ) ;
203
225
204
226
wrapper . setProps ( { value : 'foo' } ) ;
205
227
wrapper . setProps ( { value : 'bar' } ) ;
206
228
wrapper . setProps ( { value : 'bar' } ) ;
207
229
230
+ sinon . assert . calledTwice ( spy ) ;
231
+
208
232
// Simulate typing: The #value changes but at the same time, the instance update
209
233
// its own data so instance.getData() and #value are immediately the same.
210
234
// Make sure instance.setData() is not called in this situation because it would destroy
211
235
// the selection.
212
- sandbox . stub ( vm . instance , 'getData' ) . returns ( 'barq' ) ;
236
+ wrapper . vm . $_lastEditorData = 'barq' ;
213
237
wrapper . setProps ( { value : 'barq' } ) ;
214
238
215
239
sinon . assert . calledTwice ( spy ) ;
@@ -223,6 +247,8 @@ describe( 'CKEditor Component', () => {
223
247
224
248
describe ( 'events' , ( ) => {
225
249
it ( 'emits #ready when editor is created' , done => {
250
+ Vue . config . errorHandler = done ;
251
+
226
252
Vue . nextTick ( ( ) => {
227
253
expect ( wrapper . emitted ( ) . ready . length ) . to . equal ( 1 ) ;
228
254
expect ( wrapper . emitted ( ) . ready [ 0 ] ) . to . deep . equal ( [ vm . instance ] ) ;
@@ -232,6 +258,8 @@ describe( 'CKEditor Component', () => {
232
258
} ) ;
233
259
234
260
it ( 'emits #destroy when editor is destroyed' , done => {
261
+ Vue . config . errorHandler = done ;
262
+
235
263
const { wrapper, vm } = createComponent ( ) ;
236
264
237
265
Vue . nextTick ( ( ) => {
@@ -244,7 +272,9 @@ describe( 'CKEditor Component', () => {
244
272
} ) ;
245
273
} ) ;
246
274
247
- it ( 'emits #input when editor data changes' , done => {
275
+ it ( 'emits debounced #input when editor data changes' , done => {
276
+ Vue . config . errorHandler = done ;
277
+
248
278
sandbox . stub ( ModelDocument . prototype , 'on' ) ;
249
279
sandbox . stub ( MockEditor . prototype , 'getData' ) . returns ( 'foo' ) ;
250
280
@@ -260,16 +290,20 @@ describe( 'CKEditor Component', () => {
260
290
261
291
on . firstCall . args [ 1 ] ( evtStub ) ;
262
292
263
- expect ( wrapper . emitted ( ) . input . length ) . to . equal ( 1 ) ;
264
- expect ( wrapper . emitted ( ) . input [ 0 ] ) . to . deep . equal ( [
265
- 'foo' , evtStub , vm . instance
266
- ] ) ;
293
+ setTimeout ( ( ) => {
294
+ expect ( wrapper . emitted ( ) . input . length ) . to . equal ( 1 ) ;
295
+ expect ( wrapper . emitted ( ) . input [ 0 ] ) . to . deep . equal ( [
296
+ 'foo' , evtStub , vm . instance
297
+ ] ) ;
267
298
268
- done ( ) ;
299
+ done ( ) ;
300
+ } , 350 ) ;
269
301
} ) ;
270
302
} ) ;
271
303
272
304
it ( 'emits #focus when editor editable is focused' , done => {
305
+ Vue . config . errorHandler = done ;
306
+
273
307
sandbox . stub ( ViewlDocument . prototype , 'on' ) ;
274
308
275
309
Vue . nextTick ( ( ) => {
@@ -294,6 +328,8 @@ describe( 'CKEditor Component', () => {
294
328
} ) ;
295
329
296
330
it ( 'emits #blur when editor editable is focused' , done => {
331
+ Vue . config . errorHandler = done ;
332
+
297
333
sandbox . stub ( ViewlDocument . prototype , 'on' ) ;
298
334
299
335
Vue . nextTick ( ( ) => {
0 commit comments