Detect empty input and throw a helpful error (#2687)

This commit is contained in:
Jacob
2021-05-03 04:29:51 -04:00
committed by GitHub
parent a688468378
commit 52e4543d31
4 changed files with 20 additions and 12 deletions

View File

@@ -7,6 +7,18 @@ const fixtures = require('../fixtures');
describe('Raw pixel data', function () {
describe('Raw pixel input', function () {
it('Empty data', function () {
assert.throws(function () {
sharp(Buffer.from(''));
}, /empty/);
assert.throws(function () {
sharp(new Uint8Array(0));
}, /empty/);
assert.throws(function () {
sharp(new Uint8ClampedArray(0));
}, /empty/);
});
it('Missing options', function () {
assert.throws(function () {
sharp({ raw: {} });