Skip to content

Commit

Permalink
tests: Mock DragEvent and ClipboardEvent
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliushaertl committed Oct 29, 2023
1 parent 445c7cd commit d60a2de
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/tests/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit d60a2de

Please sign in to comment.