Skip to content

Commit 403d06f

Browse files
Adding test
1 parent c388b6c commit 403d06f

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/unit/vuedraggable.spec.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,47 @@ describe("draggable.vue when initialized with a transition group", () => {
11521152
})
11531153
});
11541154

1155+
describe("when calling onMove", () => {
1156+
let originalEvt;
1157+
let move;
1158+
let doMove;
1159+
1160+
beforeEach(() => {
1161+
move = jest.fn();
1162+
wrapper.setProps({ move });
1163+
evt = {
1164+
to: element.children[0],
1165+
related: element.children[0].children[1],
1166+
willInsertAfter: false
1167+
};
1168+
originalEvt = {
1169+
domInfo: true
1170+
};
1171+
doMove = () => getEvent("onMove")(evt, originalEvt);
1172+
});
1173+
1174+
it("calls move with list information", () => {
1175+
const expectedEvt = {
1176+
draggedContext: {
1177+
element: "b",
1178+
futureIndex: 1,
1179+
index: 1
1180+
},
1181+
relatedContext: {
1182+
component: vm,
1183+
element: "b",
1184+
index: 1,
1185+
list: ["a", "b", "c"]
1186+
},
1187+
to: element.children[0],
1188+
related: element.children[0].children[1],
1189+
willInsertAfter: false
1190+
};
1191+
doMove();
1192+
expect(move.mock.calls).toEqual([[expectedEvt, originalEvt]]);
1193+
});
1194+
});
1195+
11551196
describe("when sending DragEnd", () => {
11561197
let endEvt;
11571198
beforeEach(() => {

0 commit comments

Comments
 (0)