From d60a2de866f4eb2756c4de1099b004012c432e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Sun, 29 Oct 2023 20:09:22 +0100 Subject: [PATCH] tests: Mock DragEvent and ClipboardEvent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- src/tests/setup.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/tests/setup.js b/src/tests/setup.js index 10ff4192baa..a884d3831b7 100644 --- a/src/tests/setup.js +++ b/src/tests/setup.js @@ -77,3 +77,27 @@ Vue.prototype.t = global.t Vue.prototype.n = global.n Vue.prototype.OC = OC Vue.prototype.OCA = OCA + +// Mock ClipboardEvent and DragEvent as long as jsdom is used +// https://github.com/ueberdosis/tiptap/issues/4455 +class ClipboardEventMock extends Event { + constructor(type, eventInitDict) { + super(type, eventInitDict); + this.clipboardData = { + getData: jest.fn(), + setData: jest.fn(), + }; + } +} +global.ClipboardEvent = ClipboardEventMock; + +class DragEventMock extends Event { + constructor(type, eventInitDict) { + super(type, eventInitDict); + this.dataTransfer = { + getData: jest.fn(), + setData: jest.fn(), + }; + } +} +global.DragEvent = DragEventMock;