(contentType, value)
| 38 | } |
| 39 | |
| 40 | export const pasteContent = async (contentType, value) => { |
| 41 | let data |
| 42 | |
| 43 | if (typeof contentType === "object") { |
| 44 | data = contentType |
| 45 | } else { |
| 46 | data = { [contentType]: value } |
| 47 | } |
| 48 | |
| 49 | const testClipboardData = { |
| 50 | getData: (type) => data[type], |
| 51 | types: Object.keys(data), |
| 52 | items: Object.values(data), |
| 53 | } |
| 54 | |
| 55 | if (testClipboardData.types.includes("Files")) { |
| 56 | testClipboardData.files = testClipboardData.items |
| 57 | } |
| 58 | |
| 59 | triggerInputEvent(document.activeElement, "beforeinput", { |
| 60 | inputType: "insertFromPaste", |
| 61 | dataTransfer: testClipboardData, |
| 62 | }) |
| 63 | |
| 64 | triggerEvent(document.activeElement, "paste", { testClipboardData }) |
| 65 | |
| 66 | await nextFrame() |
| 67 | } |
| 68 | |
| 69 | export const createFile = function (properties = {}) { |
| 70 | const file = { |
no test coverage detected
searching dependent graphs…