allow disproportionate memes
This commit is contained in:
+13
-14
@@ -40,28 +40,27 @@ test('rejects gif uploads', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('rejects non-square images when square uploads are required', () => {
|
||||
test('accepts non-square png uploads', () => {
|
||||
const png = encodePng(32, 24, () => [0, 255, 65, 255]);
|
||||
assert.throws(
|
||||
() => validateImage(png, {
|
||||
maxBytes: 5 * 1024 * 1024,
|
||||
maxWidth: 6000,
|
||||
maxHeight: 6000,
|
||||
maxPixels: 20_000_000,
|
||||
requireSquare: true
|
||||
}),
|
||||
/square/
|
||||
);
|
||||
const image = validateImage(png, {
|
||||
maxBytes: 5 * 1024 * 1024,
|
||||
maxWidth: 6000,
|
||||
maxHeight: 6000,
|
||||
maxPixels: 20_000_000
|
||||
});
|
||||
|
||||
assert.equal(image.width, 32);
|
||||
assert.equal(image.height, 24);
|
||||
});
|
||||
|
||||
test('normalizes png uploads to square webp', async () => {
|
||||
const png = encodePng(32, 32, () => [0, 255, 65, 255]);
|
||||
test('normalizes png uploads to webp while preserving aspect ratio', async () => {
|
||||
const png = encodePng(32, 24, () => [0, 255, 65, 255]);
|
||||
const normalized = await normalizeToWebp(png);
|
||||
|
||||
assert.equal(normalized.image.mime, 'image/webp');
|
||||
assert.equal(normalized.image.ext, 'webp');
|
||||
assert.equal(normalized.image.width, 32);
|
||||
assert.equal(normalized.image.height, 32);
|
||||
assert.equal(normalized.image.height, 24);
|
||||
assert.equal(normalized.buffer.subarray(0, 4).toString('ascii'), 'RIFF');
|
||||
assert.equal(normalized.buffer.subarray(8, 12).toString('ascii'), 'WEBP');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user