You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/unit/vuedraggable.spec.js
+72-11Lines changed: 72 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -103,13 +103,13 @@ describe("draggable.vue when initialized with list", () => {
103
103
wrapper=shallowMount(draggable,{
104
104
attachToDocument: true,
105
105
propsData: {
106
-
element: "li"
106
+
element: "li"
107
107
},
108
108
slots: {
109
109
default: ""
110
110
}
111
111
});
112
-
expect(console.warn).toBeCalledWith("Element props is deprecated please use tag props instead. See https://github.com/SortableJS/Vue.Draggable/blob/master/documentation/migrate.md#element-props");
112
+
expect(console.warn).toBeCalledWith("Element props is deprecated please use tag props instead. See https://github.com/SortableJS/Vue.Draggable/blob/master/documentation/migrate.md#element-props");
113
113
});
114
114
115
115
});
@@ -576,6 +576,70 @@ describe("draggable.vue when initialized with list", () => {
576
576
})
577
577
});
578
578
579
+
580
+
describe("when initiating a drag operation in clone context",()=>{
581
+
letevt;
582
+
beforeEach(()=>{
583
+
resetMocks();
584
+
wrapper=shallowMount(draggable,{
585
+
attachToDocument: true,
586
+
propsData: {
587
+
list: items
588
+
},
589
+
attrs: {
590
+
group: {pull: "clone"}
591
+
},
592
+
slots: {
593
+
default: items.map(item=>`<div>${item}</div>`),
594
+
}
595
+
});
596
+
vm=wrapper.vm;
597
+
element=wrapper.element;
598
+
item=element.children[1];
599
+
evt={ item };
600
+
conststart=getEvent("onStart");
601
+
start(evt);
602
+
});
603
+
604
+
describe("when remove is called",()=>{
605
+
beforeEach(()=>{
606
+
varclone=item.cloneNode(true);
607
+
wrapper.element.insertBefore(clone,item);
608
+
wrapper.element.removeChild(item);
609
+
constremove=getEvent("onRemove");
610
+
remove({
611
+
item,
612
+
clone,
613
+
oldIndex: 1
614
+
});
615
+
})
616
+
617
+
it("DOM changes should be reverted",async()=>{
618
+
awaitVue.nextTick();
619
+
expect(wrapper.html()).toEqual(initialRenderRaw);
620
+
})
621
+
622
+
it("list should be not updated",async()=>{
623
+
awaitVue.nextTick();
624
+
expect(vm.list).toEqual(["a","b","c"]);
625
+
})
626
+
627
+
it("does not send a remove event",async()=>{
628
+
awaitVue.nextTick();
629
+
expect(wrapper.emitted().remove).toEqual([[{
630
+
item,
631
+
clone: item,
632
+
oldIndex: 1
633
+
}]]);
634
+
})
635
+
636
+
it("does not send a change event",async()=>{
637
+
awaitVue.nextTick();
638
+
expect(wrapper.emitted().change).toBeUndefined();
639
+
})
640
+
})
641
+
});
642
+
579
643
describe("when attribute changes:",()=>{
580
644
const{ error }=console;
581
645
beforeEach(()=>{
@@ -597,14 +661,11 @@ describe("draggable.vue when initialized with list", () => {
0 commit comments