@@ -721,7 +721,7 @@ describe("draggable.vue when initialized with list", () => {
721
721
itemKey : k => k
722
722
} ,
723
723
slots : {
724
- item : ( { element} ) => h ( "div" , null , element )
724
+ item : ( { element } ) => h ( "div" , null , element )
725
725
}
726
726
} ) ;
727
727
vm = wrapper . vm ;
@@ -1404,3 +1404,74 @@ describe("draggable.vue when initialized with a transition group", () => {
1404
1404
} ) ;
1405
1405
} ) ;
1406
1406
} ) ;
1407
+
1408
+ describe ( "when using only footer slot" , ( ) => {
1409
+ beforeEach ( async ( ) => {
1410
+ resetMocks ( ) ;
1411
+
1412
+ wrapper = mount ( draggable , {
1413
+ props : {
1414
+ tag : "ul" ,
1415
+ list : [ ] ,
1416
+ itemKey : k => k
1417
+ } ,
1418
+ slots : {
1419
+ item : ( { element } ) => h ( "li" , null , element ) ,
1420
+ footer : ( ) => h ( "footer" , null , "I am the footer" )
1421
+ }
1422
+ } ) ;
1423
+ vm = wrapper . vm ;
1424
+ element = wrapper . element ;
1425
+ } ) ;
1426
+
1427
+ it ( "renders correctly" , ( ) => {
1428
+ const expectedDOM = `<ul><footer>I am the footer</footer></ul>` ;
1429
+ expectHTML ( wrapper , expectedDOM ) ;
1430
+ } ) ;
1431
+
1432
+ describe ( "when add is called on an empty list with" , ( ) => {
1433
+ let newItem ;
1434
+ const expectedDOMAfterUpdate = `<ul><li data-draggable="true">1</li><footer>I am the footer</footer></ul>` ;
1435
+ beforeEach ( async ( ) => {
1436
+ await nextTick ( ) ;
1437
+
1438
+ newItem = document . createElement ( "li" ) ;
1439
+ const newContent = document . createTextNode ( "1" ) ;
1440
+ newItem . appendChild ( newContent ) ;
1441
+ newItem . _underlying_vm_ = "1" ;
1442
+ const last = element . children [ 0 ] ;
1443
+ element . insertBefore ( newItem , last ) ;
1444
+
1445
+ const add = getEvent ( "onAdd" ) ;
1446
+ add ( {
1447
+ item : newItem ,
1448
+ newIndex : 0
1449
+ } ) ;
1450
+ } ) ;
1451
+
1452
+ it ( "DOM changes should be performed" , async ( ) => {
1453
+ await nextTick ( ) ;
1454
+ expectHTML ( wrapper , expectedDOMAfterUpdate ) ;
1455
+ } ) ;
1456
+
1457
+ it ( "list should be updated" , async ( ) => {
1458
+ await nextTick ( ) ;
1459
+ expect ( vm . list ) . toEqual ( [ "1" ] ) ;
1460
+ } ) ;
1461
+
1462
+ it ( "sends a update event" , async ( ) => {
1463
+ await nextTick ( ) ;
1464
+ const expectedEvt = {
1465
+ item : newItem ,
1466
+ newIndex : 0
1467
+ } ;
1468
+ expect ( wrapper . emitted ( ) . add ) . toEqual ( [ [ expectedEvt ] ] ) ;
1469
+ } ) ;
1470
+
1471
+ it ( "sends a change event" , async ( ) => {
1472
+ await nextTick ( ) ;
1473
+ const expectedEvt = { added : { element : "1" , newIndex : 0 } } ;
1474
+ expect ( wrapper . emitted ( ) . change ) . toEqual ( [ [ expectedEvt ] ] ) ;
1475
+ } ) ;
1476
+ } ) ;
1477
+ } ) ;
0 commit comments