16 lines
675 B
TypeScript
16 lines
675 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { LARGE_IMAGE_EDGE, MAX_IMAGE_BYTES, 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_BYTES).toBe(20 * 1024 * 1024)
|
|
expect(MAX_IMAGE_PIXELS).toBe(64_000_000)
|
|
expect(LARGE_IMAGE_EDGE).toBe(3_200)
|
|
})
|
|
})
|