Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding types properties into mocked DataTransfer #191

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions addon-test-support/helpers/mock-event.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
class DataTransfer {
constructor() {
this.data = {};
this.types = [];
}

setData(type, value) {
const _type = type === 'Text' ? 'text/plain' : type;

if (!this.types.includes(_type)) {
this.types.push(_type);
}

this.data[type] = value;
return this;
}

getData(type = "Text") {
getData(type = 'Text') {
return this.data[type];
}

setDragImage() {
}
setDragImage() {}
}

export default class MockEvent {
constructor(options = {}) {
this.dataTransfer = new DataTransfer();
this.dataTransfer.setData('Text', options.dataTransferData);
this.setProperties(options)
this.setProperties(options);
}

useDataTransferData(otherEvent) {
Expand All @@ -35,15 +41,13 @@ export default class MockEvent {
return this;
}

preventDefault() {
}
preventDefault() {}

stopPropagation() {
}
stopPropagation() {}
}

export function createDomEvent(type) {
let event = document.createEvent("CustomEvent");
let event = document.createEvent('CustomEvent');
event.initCustomEvent(type, true, true, null);
event.dataTransfer = new DataTransfer();
return event;
Expand Down