import { describe, test, it, expect } from 'vitest' import FileUtils from '~/services/utils/fileUtils' import 'blob-polyfill' describe('newBlob', () => { test('defaultFiletype', async () => { const blob = FileUtils.newBlob('test') expect(await blob.text()).toEqual('test') expect(await blob.type).toEqual('image/jpeg') }) test('otherFiletype', async () => { const blob = FileUtils.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 FileUtils.blobToBase64(blob)).toEqual( 'data:image/jpeg;base64,Zm9v', ) }) })