summaryrefslogtreecommitdiff
path: root/packages/core/src/utils/fileUtils.test.ts
diff options
context:
space:
mode:
authorSanthosh Kumar <[email protected]>2025-07-02 00:52:32 +0530
committerGitHub <[email protected]>2025-07-01 19:22:32 +0000
commit0275ab0108e9a411d90d8ef8c8d70e21e498d81a (patch)
tree702acf3ad2746005bae13bff1502f39c508f8c3f /packages/core/src/utils/fileUtils.test.ts
parent63ed8d649913df05736d47ff03deb7741603f73d (diff)
feat: add audio and video support to read_file (#2556)
Diffstat (limited to 'packages/core/src/utils/fileUtils.test.ts')
-rw-r--r--packages/core/src/utils/fileUtils.test.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/packages/core/src/utils/fileUtils.test.ts b/packages/core/src/utils/fileUtils.test.ts
index 4f4c7c1e..0455b6e1 100644
--- a/packages/core/src/utils/fileUtils.test.ts
+++ b/packages/core/src/utils/fileUtils.test.ts
@@ -211,6 +211,16 @@ describe('fileUtils', () => {
expect(detectFileType('file.pdf')).toBe('pdf');
});
+ it('should detect audio type by extension', () => {
+ mockMimeLookup.mockReturnValueOnce('audio/mpeg');
+ expect(detectFileType('song.mp3')).toBe('audio');
+ });
+
+ it('should detect video type by extension', () => {
+ mockMimeLookup.mockReturnValueOnce('video/mp4');
+ expect(detectFileType('movie.mp4')).toBe('video');
+ });
+
it('should detect known binary extensions as binary (e.g. .zip)', () => {
mockMimeLookup.mockReturnValueOnce('application/zip');
expect(detectFileType('archive.zip')).toBe('binary');
@@ -427,5 +437,23 @@ describe('fileUtils', () => {
);
expect(result.isTruncated).toBe(true);
});
+
+ it('should return an error if the file size exceeds 20MB', async () => {
+ // Create a file just over 20MB
+ const twentyOneMB = 21 * 1024 * 1024;
+ const buffer = Buffer.alloc(twentyOneMB, 0x61); // Fill with 'a'
+ actualNodeFs.writeFileSync(testTextFilePath, buffer);
+
+ const result = await processSingleFileContent(
+ testTextFilePath,
+ tempRootDir,
+ );
+
+ expect(result.error).toContain('File size exceeds the 20MB limit');
+ expect(result.returnDisplay).toContain(
+ 'File size exceeds the 20MB limit',
+ );
+ expect(result.llmContent).toContain('File size exceeds the 20MB limit');
+ });
});
});