I am attempting to create a mocked File for testing an Angular unit test, and I am encountering some challenges.
Below is the code snippet from the spec file:
let content = "Hello Zip";
let data = new Blob([content], { type: 'application/zip' });
let arrayOfBlob = new Array<Blob>();
arrayOfBlob.push(data);
let applicationZip = new File(arrayOfBlob, "Mock.zip");
When I try to output applicationZip
:
console.log(applicationZip);
The resulting object includes:
lastModified: 1492785142174
lastModifiedDate: Fri Apr 21 2017 10:32:22 GMT-0400
name:"Mock.zip"
size:9
type: ""
webkitRelativePath:""
proto: File
One of the methods that I need to test involves verifying the validity of the file's mime type.
However, in my current implementation, the type
property always remains null. Even when attempting to set it to plain/text
, there is no change in behavior.
It seems like there might be an issue with how I'm creating the mock File, but I can't identify the error.