|
|
@@ -1,4 +1,4 @@
|
|
|
-import { formatFileSize, validateBackgroundFile } from '@/utils/teamBackgroundFile'
|
|
|
+import { ACCEPT, formatFileSize, validateBackgroundFile } from '@/utils/teamBackgroundFile'
|
|
|
import request from '@/utils/request2'
|
|
|
import {
|
|
|
completePublicUpload,
|
|
|
@@ -42,9 +42,35 @@ test('rejects archives, 50MB overflow and names over 255 chars', () => {
|
|
|
expect(validateBackgroundFile({ name: `${'a'.repeat(252)}.pdf`, size: 1 })).toContain('255')
|
|
|
})
|
|
|
|
|
|
-test('formats byte counts for the table', () => {
|
|
|
+test('accepts a filename containing exactly 255 characters', () => {
|
|
|
+ const name = `${'a'.repeat(251)}.pdf`
|
|
|
+
|
|
|
+ expect(name).toHaveLength(255)
|
|
|
+ expect(validateBackgroundFile({ name, size: 1 })).toBe('')
|
|
|
+})
|
|
|
+
|
|
|
+test('accepts a file containing exactly 50MiB', () => {
|
|
|
+ expect(validateBackgroundFile({ name: 'file.pdf', size: 50 * 1024 * 1024 })).toBe('')
|
|
|
+})
|
|
|
+
|
|
|
+test('rejects missing, unnamed and zero-size files', () => {
|
|
|
+ expect(validateBackgroundFile()).toBe('请选择非空文件')
|
|
|
+ expect(validateBackgroundFile({ name: '', size: 1 })).toBe('请选择非空文件')
|
|
|
+ expect(validateBackgroundFile({ name: 'empty.pdf', size: 0 })).toBe('请选择非空文件')
|
|
|
+})
|
|
|
+
|
|
|
+test('exports the exact file-picker accept list', () => {
|
|
|
+ expect(ACCEPT).toBe('.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.md,.csv')
|
|
|
+})
|
|
|
+
|
|
|
+test('formats byte counts across byte, KB and MB thresholds', () => {
|
|
|
expect(formatFileSize(0)).toBe('0 B')
|
|
|
+ expect(formatFileSize(1)).toBe('1 B')
|
|
|
+ expect(formatFileSize(1023)).toBe('1023 B')
|
|
|
+ expect(formatFileSize(1024)).toBe('1 KB')
|
|
|
expect(formatFileSize(1536)).toBe('1.5 KB')
|
|
|
+ expect(formatFileSize(1024 * 1024)).toBe('1 MB')
|
|
|
+ expect(formatFileSize(1.5 * 1024 * 1024)).toBe('1.5 MB')
|
|
|
})
|
|
|
|
|
|
test('uses backend-controlled authenticated file routes', () => {
|