@@ -255,7 +255,7 @@ describe("draggable.vue", () => {
255
255
await Vue . nextTick ( ) ;
256
256
expect ( vm . list ) . toEqual ( [ "a" , "c" ] ) ;
257
257
} )
258
-
258
+
259
259
it ( "sends a remove event" , async ( ) => {
260
260
await Vue . nextTick ( ) ;
261
261
const expectedEvt = { item, oldIndex : 2 } ;
@@ -268,5 +268,47 @@ describe("draggable.vue", () => {
268
268
expect ( wrapper . emitted ( ) . change ) . toEqual ( [ [ expectedEvt ] ] ) ;
269
269
} )
270
270
} )
271
+
272
+ describe ( "when update is called" , ( ) => {
273
+ beforeEach ( ( ) => {
274
+ const firstDraggable = element . children [ 1 ] ;
275
+ element . removeChild ( item ) ;
276
+ element . insertBefore ( item , firstDraggable ) ;
277
+ const update = getEvent ( "onUpdate" ) ;
278
+ update ( {
279
+ item,
280
+ oldIndex : 2 ,
281
+ newIndex : 1 ,
282
+ from : element
283
+ } ) ;
284
+ } )
285
+
286
+ it ( "DOM changes should be reverted" , async ( ) => {
287
+ await Vue . nextTick ( ) ;
288
+ expect ( wrapper . html ( ) ) . toEqual ( initialRender ) ;
289
+ } )
290
+
291
+ it ( "list should be updated" , async ( ) => {
292
+ await Vue . nextTick ( ) ;
293
+ expect ( vm . list ) . toEqual ( [ "b" , "a" , "c" ] ) ;
294
+ } )
295
+
296
+ it ( "sends a update event" , async ( ) => {
297
+ await Vue . nextTick ( ) ;
298
+ const expectedEvt = {
299
+ item,
300
+ oldIndex : 2 ,
301
+ newIndex : 1 ,
302
+ from : element
303
+ } ;
304
+ expect ( wrapper . emitted ( ) . update ) . toEqual ( [ [ expectedEvt ] ] ) ;
305
+ } )
306
+
307
+ it ( "sends a change event" , async ( ) => {
308
+ await Vue . nextTick ( ) ;
309
+ const expectedEvt = { moved : { element : "b" , oldIndex : 1 , newIndex : 0 } } ;
310
+ expect ( wrapper . emitted ( ) . change ) . toEqual ( [ [ expectedEvt ] ] ) ;
311
+ } )
312
+ } )
271
313
} ) ;
272
314
} ) ;
0 commit comments