Skip to content

Commit d60a2de

Browse files
committed
tests: Mock DragEvent and ClipboardEvent
Signed-off-by: Julius Härtl <jus@bitgrid.net>
1 parent 445c7cd commit d60a2de

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/tests/setup.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,27 @@ Vue.prototype.t = global.t
7777
Vue.prototype.n = global.n
7878
Vue.prototype.OC = OC
7979
Vue.prototype.OCA = OCA
80+
81+
// Mock ClipboardEvent and DragEvent as long as jsdom is used
82+
// https://github.com/ueberdosis/tiptap/issues/4455
83+
class ClipboardEventMock extends Event {
84+
constructor(type, eventInitDict) {
85+
super(type, eventInitDict);
86+
this.clipboardData = {
87+
getData: jest.fn(),
88+
setData: jest.fn(),
89+
};
90+
}
91+
}
92+
global.ClipboardEvent = ClipboardEventMock;
93+
94+
class DragEventMock extends Event {
95+
constructor(type, eventInitDict) {
96+
super(type, eventInitDict);
97+
this.dataTransfer = {
98+
getData: jest.fn(),
99+
setData: jest.fn(),
100+
};
101+
}
102+
}
103+
global.DragEvent = DragEventMock;

0 commit comments

Comments
 (0)