Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
describe('utils/blob.js', () => {
const blob = blobUtil.createBlob(['hello world'], { type: 'text/plain' })
let base64 = null
beforeAll(async () => {
base64 = await blobUtil.blobToBase64String(blob)
})
it('isBase64() works as expected', () => {
expect(isBase64(base64)).toEqual(true)
expect(isBase64()).toEqual(false)
})
it('isBlobbable() works as expected', () => {
expect(isBlobbable(blob)).toEqual(true)
expect(isBlobbable('foo')).toEqual(false)
})
export function getBlobUrl(file) {
if (file.blobUrl) {
blobUtil.revokeObjectURL(file.blobUrl);
}
const fileBlob = blobUtil.createBlob([file.content], { type: 'text/plain' });
const blobURL = blobUtil.createObjectURL(fileBlob);
return blobURL;
}