Add getImageBlob() support function for tests

This commit is contained in:
Dan Stillman 2021-03-21 14:36:23 -04:00
parent 06b28194da
commit b566c06f93
2 changed files with 12 additions and 7 deletions

View file

@ -981,6 +981,17 @@ async function createEmbeddedImage(parentItem, options = {}) {
}
async function getImageBlob() {
var path = OS.Path.join(getTestDataDirectory().path, 'test.png');
var imageData = await Zotero.File.getBinaryContentsAsync(path);
var array = new Uint8Array(imageData.length);
for (let i = 0; i < imageData.length; i++) {
array[i] = imageData.charCodeAt(i);
}
return new Blob([array], { type: 'image/png' });
}
/**
* Sets the fake XHR server to response to a given response
*