@@ -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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user