@lobehub/chat
Version:
Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.
30 lines (24 loc) • 992 B
text/typescript
import { describe, expect, it } from 'vitest';
import { parseDataUri } from './uriParser';
describe('parseDataUri', () => {
it('should parse a valid data URI', () => {
const dataUri = 'data:image/png;base64,abc';
const result = parseDataUri(dataUri);
expect(result).toEqual({ base64: 'abc', mimeType: 'image/png', type: 'base64' });
});
it('should parse a valid URL', () => {
const url = 'https://example.com/image.jpg';
const result = parseDataUri(url);
expect(result).toEqual({ base64: null, mimeType: null, type: 'url' });
});
it('should return null for an invalid input', () => {
const invalidInput = 'invalid-data';
const result = parseDataUri(invalidInput);
expect(result).toEqual({ base64: null, mimeType: null, type: null });
});
it('should handle an empty input', () => {
const emptyInput = '';
const result = parseDataUri(emptyInput);
expect(result).toEqual({ base64: null, mimeType: null, type: null });
});
});