Add type, size, and arrayBuffer properties to the File object
This commit is contained in:
@@ -14,11 +14,14 @@ function createTestFile(bytes: Uint8Array | Buffer, name: string, type: string):
|
|||||||
const arrayBuffer = new ArrayBuffer(bytes.byteLength);
|
const arrayBuffer = new ArrayBuffer(bytes.byteLength);
|
||||||
new Uint8Array(arrayBuffer).set(bytes);
|
new Uint8Array(arrayBuffer).set(bytes);
|
||||||
|
|
||||||
return Object.assign(new Blob([arrayBuffer], { type }), {
|
return {
|
||||||
name,
|
name,
|
||||||
|
type,
|
||||||
lastModified: Date.now(),
|
lastModified: Date.now(),
|
||||||
webkitRelativePath: ""
|
size: arrayBuffer.byteLength,
|
||||||
}) as File;
|
webkitRelativePath: "",
|
||||||
|
arrayBuffer: async () => arrayBuffer.slice(0)
|
||||||
|
} as File;
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("model import", () => {
|
describe("model import", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user