mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(Basic LLM Chain Node): Use correct mimetype for binary data (#12978)
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import type { IBinaryData } from 'n8n-workflow';
|
||||
|
||||
import { dataUriFromImageData, UnsupportedMimeTypeError } from '../utils';
|
||||
|
||||
describe('dataUriFromImageData', () => {
|
||||
it('should not throw an error on images', async () => {
|
||||
const mockBuffer = Buffer.from('Test data');
|
||||
const mockBinaryData = mock<IBinaryData>({ mimeType: 'image/jpeg' });
|
||||
|
||||
const dataUri = dataUriFromImageData(mockBinaryData, mockBuffer);
|
||||
expect(dataUri).toBe('data:image/jpeg;base64,VGVzdCBkYXRh');
|
||||
});
|
||||
|
||||
it('should throw an UnsupportetMimeTypeError on non-images', async () => {
|
||||
const mockBuffer = Buffer.from('Test data');
|
||||
const mockBinaryData = mock<IBinaryData>({ mimeType: 'text/plain' });
|
||||
|
||||
expect(() => {
|
||||
dataUriFromImageData(mockBinaryData, mockBuffer);
|
||||
}).toThrow(UnsupportedMimeTypeError);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user