refactor: move document domain core to lib/document/
Moves ~25 components, utils (search, filename, groupDocuments, documentStatusLabel, validateFile), bulkSelection store, and TranscriptionSection sub-component. Fixes broken relative imports. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
36
frontend/src/lib/document/validateFile.spec.ts
Normal file
36
frontend/src/lib/document/validateFile.spec.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { validateFile, MAX_SIZE_BYTES } from './validateFile';
|
||||
|
||||
function makeFile(type: string, size: number): File {
|
||||
return new File(['x'.repeat(Math.min(size, 100))], 'test.file', { type });
|
||||
}
|
||||
|
||||
describe('validateFile', () => {
|
||||
it('returns null for a valid PDF under 50 MB', () => {
|
||||
const file = makeFile('application/pdf', 1024);
|
||||
expect(validateFile(file)).toBeNull();
|
||||
});
|
||||
|
||||
it('returns null for a valid JPEG', () => {
|
||||
expect(validateFile(makeFile('image/jpeg', 1024))).toBeNull();
|
||||
});
|
||||
|
||||
it('returns null for a valid PNG', () => {
|
||||
expect(validateFile(makeFile('image/png', 1024))).toBeNull();
|
||||
});
|
||||
|
||||
it('returns null for a valid TIFF', () => {
|
||||
expect(validateFile(makeFile('image/tiff', 1024))).toBeNull();
|
||||
});
|
||||
|
||||
it('returns "type" for an unsupported MIME type', () => {
|
||||
const file = makeFile('text/plain', 100);
|
||||
expect(validateFile(file)).toBe('type');
|
||||
});
|
||||
|
||||
it('returns "size" for a file exceeding 50 MB', () => {
|
||||
const oversized = new File(['x'], 'big.pdf', { type: 'application/pdf' });
|
||||
Object.defineProperty(oversized, 'size', { value: MAX_SIZE_BYTES + 1 });
|
||||
expect(validateFile(oversized)).toBe('size');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user