Files
guanwang/tests/image-validation.test.ts

14 lines
548 B
TypeScript

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)
})
})