Skip to content

Commit 6c2d0d6

Browse files
Testing move props
1 parent b507037 commit 6c2d0d6

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

tests/unit/vuedraggable.spec.js

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,50 @@ describe("draggable.vue when initialized with list", () => {
301301
});
302302
})
303303

304+
describe("when calling onMove", () => {
305+
let evt;
306+
let originalEvt;
307+
let move;
308+
let doMove;
309+
310+
beforeEach(() => {
311+
//item = element.children[2];
312+
evt = {
313+
to: element,
314+
related: element,
315+
willInsertAfter: false
316+
};
317+
originalEvt = {};
318+
move = getEvent("onMove");
319+
doMove = () => move(evt, originalEvt);
320+
});
321+
322+
it("returns true when move props is null", () => {
323+
const actual = doMove();
324+
expect(actual).toBe(true);
325+
});
326+
327+
describe("when move is set", () => {
328+
let move;
329+
beforeEach(() => {
330+
move = jest.fn();
331+
wrapper.setProps({ move });
332+
})
333+
334+
test.each([
335+
true,
336+
false
337+
])(
338+
"returns move result %o",
339+
(result) => {
340+
move.mockImplementation(() => result)
341+
const actual = doMove();
342+
expect(actual).toBe(result);
343+
}
344+
)
345+
});
346+
});
347+
304348
describe("when remove is called", () => {
305349
beforeEach(() => {
306350
element.removeChild(item);
@@ -430,14 +474,12 @@ describe("draggable.vue when initialized with list", () => {
430474
])(
431475
"when option %s change for value %o, calls sortable option with %s attribute",
432476
(attribute, value, sortableAttribute) => {
433-
wrapper.setProps({options: { [attribute]: value }});
477+
wrapper.setProps({ options: { [attribute]: value } });
434478
expect(SortableFake.option).toHaveBeenCalledWith(sortableAttribute, value);
435479
}
436480
);
437-
438481
})
439482

440-
441483
describe("draggable.vue when initialized with value", () => {
442484
beforeEach(() => {
443485
Sortable.mockClear();

0 commit comments

Comments
 (0)