UNPKG

vue3-dnd

Version:

Drag and Drop for Vue Composition API

84 lines (83 loc) 2.95 kB
"use strict"; var _dropTargetImpl = require("../DropTargetImpl"); var _vitest = require("vitest"); (0, _vitest).describe("The Hooks DropTargetImpl", function() { (0, _vitest).describe("canDrag()", function() { (0, _vitest).it("can determine if a item can drag", function() { var monitor = { getItem: function() { return {}; } }; var impl = new _dropTargetImpl.DropTargetImpl({}, monitor); (0, _vitest).expect(impl.canDrop()).toEqual(true); impl = new _dropTargetImpl.DropTargetImpl({ canDrop: function canDrop(_item, mon) { (0, _vitest).expect(mon).toEqual(monitor); return false; } }, monitor); (0, _vitest).expect(impl.canDrop()).toEqual(false); }); }); (0, _vitest).describe("hover()", function() { (0, _vitest).it("will not throw if spec.hover is not defined", function() { var item = {}; var monitor = { getItem: function() { return item; } }; var impl = new _dropTargetImpl.DropTargetImpl({}, monitor); impl.hover(); }); (0, _vitest).it("will invoke hover if it is defined", function() { var item = {}; var monitor = { getItem: function() { return item; } }; var hover = _vitest.vi.fn(); var impl = new _dropTargetImpl.DropTargetImpl({ hover: hover }, monitor); impl.hover(); (0, _vitest).expect(hover.mock.calls.length).toEqual(1); (0, _vitest).expect(hover.mock.calls[0]).toEqual([ item, monitor ]); }); }); (0, _vitest).describe("drop()", function() { (0, _vitest).it("will not throw if spec.drop is not defined", function() { var item = {}; var monitor = { getItem: function() { return item; } }; var impl = new _dropTargetImpl.DropTargetImpl({}, monitor); impl.drop(); }); (0, _vitest).it("will invoke drop if it is defined", function() { var item = {}; var monitor = { getItem: function() { return item; } }; var drop = _vitest.vi.fn(); var impl = new _dropTargetImpl.DropTargetImpl({ drop: drop }, monitor); impl.drop(); (0, _vitest).expect(drop.mock.calls.length).toEqual(1); (0, _vitest).expect(drop.mock.calls[0]).toEqual([ item, monitor ]); }); }); });