fix: 明确提示超大 PNG 像素限制
This commit is contained in:
13
tests/image-validation.test.ts
Normal file
13
tests/image-validation.test.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { MAX_IMAGE_PIXELS, isSharpPixelLimitError } from '../server/utils/image-validation'
|
||||
|
||||
describe('图片上传校验', () => {
|
||||
it('识别 Sharp 像素上限错误', () => {
|
||||
expect(isSharpPixelLimitError(new Error('Input image exceeds pixel limit'))).toBe(true)
|
||||
})
|
||||
|
||||
it('不把普通解析错误误判为像素过大', () => {
|
||||
expect(isSharpPixelLimitError(new Error('Input buffer contains unsupported image format'))).toBe(false)
|
||||
expect(MAX_IMAGE_PIXELS).toBe(40_000_000)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user