wangEditor/test/helpers/mock-file.ts

18 lines
446 B
TypeScript
Raw Permalink Normal View History

export default function mockFile(option: any) {
const name = option.name ?? 'mock.txt'
const size = option.size ?? 1024
const mimeType = option.mimeType || 'plain/txt'
function range(count: number) {
let output = ''
for (var i = 0; i < count; i++) {
output += 'a'
}
return output
}
const blob = new Blob([range(size)], { type: mimeType })
return new File([blob], name)
}