feat: 新增示例种子数据与核心单元测试

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Nixevol
2026-06-28 16:33:35 +08:00
co-authored by Cursor
parent 23cbf37aa1
commit fa61840cfb
7 changed files with 291 additions and 21 deletions
@@ -0,0 +1,18 @@
import sharp from 'sharp';
import { addWatermark } from './watermark.util';
describe('addWatermark', () => {
it('在图片上叠加水印并输出有效 JPEG', async () => {
const base = await sharp({
create: { width: 400, height: 300, channels: 3, background: { r: 200, g: 200, b: 200 } },
})
.png()
.toBuffer();
const out = await addWatermark(base, '仅供溯源核验使用');
const meta = await sharp(out).metadata();
expect(meta.format).toBe('jpeg');
expect(meta.width).toBe(400);
expect(meta.height).toBe(300);
});
});