AI Implementation feature(859): Admin Area General Settings and Categories (#21)
This commit was merged in pull request #21.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import sharp from 'sharp';
|
||||
|
||||
describe('Category icon normalization (sharp 128x128 pipeline)', () => {
|
||||
it('produces a 128x128 PNG from a larger source', async () => {
|
||||
const big = await sharp({
|
||||
create: { width: 500, height: 500, channels: 3, background: { r: 100, g: 50, b: 200 } },
|
||||
})
|
||||
.png()
|
||||
.toBuffer();
|
||||
const out = await sharp(big).resize(128, 128, { fit: 'cover' }).png().toBuffer();
|
||||
const meta = await sharp(out).metadata();
|
||||
expect(meta.width).toBe(128);
|
||||
expect(meta.height).toBe(128);
|
||||
expect(meta.format).toBe('png');
|
||||
});
|
||||
|
||||
it('produces a 128x128 PNG even when the source is smaller than 128', async () => {
|
||||
const tiny = await sharp({
|
||||
create: { width: 16, height: 16, channels: 3, background: { r: 0, g: 255, b: 0 } },
|
||||
})
|
||||
.png()
|
||||
.toBuffer();
|
||||
const out = await sharp(tiny).resize(128, 128, { fit: 'cover' }).png().toBuffer();
|
||||
const meta = await sharp(out).metadata();
|
||||
expect(meta.width).toBe(128);
|
||||
expect(meta.height).toBe(128);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user