import { describe, test, it, expect } from 'vitest' import ImageUtils from "~/services/utils/imageUtils"; import 'blob-polyfill'; describe('newBlob', () => { test('defaultFiletype', async () => { const blob = ImageUtils.newBlob('test') expect(await blob.text()).toEqual('test') expect(await blob.type).toEqual('image/jpeg') }) test('otherFiletype', async () => { const blob = ImageUtils.newBlob('test', 'image/png') expect(await blob.text()).toEqual('test') expect(await blob.type).toEqual('image/png') }) }) describe('blobToBase64', () => { test('simple blog', async () => { const blob = new Blob(['foo' as BlobPart], {type: 'image/jpeg'}) expect(await ImageUtils.blobToBase64(blob)).toEqual('data:image/jpeg;base64,Zm9v') }) })