mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Improve error messages for invalid resize parameters
Dependency version bumps and doc refresh
This commit is contained in:
@@ -141,16 +141,16 @@ describe('Crop', function () {
|
||||
it('Invalid values fail', function () {
|
||||
assert.throws(function () {
|
||||
sharp().crop(9);
|
||||
});
|
||||
}, /Expected valid crop id\/name\/strategy for crop but received 9 of type number/);
|
||||
assert.throws(function () {
|
||||
sharp().crop(1.1);
|
||||
});
|
||||
}, /Expected valid crop id\/name\/strategy for crop but received 1.1 of type number/);
|
||||
assert.throws(function () {
|
||||
sharp().crop(-1);
|
||||
});
|
||||
}, /Expected valid crop id\/name\/strategy for crop but received -1 of type number/);
|
||||
assert.throws(function () {
|
||||
sharp().crop('zoinks');
|
||||
});
|
||||
}, /Expected valid crop id\/name\/strategy for crop but received zoinks of type string/);
|
||||
});
|
||||
|
||||
it('Uses default value when none specified', function () {
|
||||
|
||||
@@ -66,37 +66,37 @@ describe('Resize dimensions', function () {
|
||||
it('Invalid width - NaN', function () {
|
||||
assert.throws(function () {
|
||||
sharp().resize('spoons', 240);
|
||||
});
|
||||
}, /Expected integer between 1 and 16383 for width but received spoons of type string/);
|
||||
});
|
||||
|
||||
it('Invalid height - NaN', function () {
|
||||
assert.throws(function () {
|
||||
sharp().resize(320, 'spoons');
|
||||
});
|
||||
}, /Expected integer between 1 and 16383 for height but received spoons of type string/);
|
||||
});
|
||||
|
||||
it('Invalid width - float', function () {
|
||||
assert.throws(function () {
|
||||
sharp().resize(1.5, 240);
|
||||
});
|
||||
}, /Expected integer between 1 and 16383 for width but received 1.5 of type number/);
|
||||
});
|
||||
|
||||
it('Invalid height - float', function () {
|
||||
assert.throws(function () {
|
||||
sharp().resize(320, 1.5);
|
||||
});
|
||||
}, /Expected integer between 1 and 16383 for height but received 1.5 of type number/);
|
||||
});
|
||||
|
||||
it('Invalid width - too large', function () {
|
||||
assert.throws(function () {
|
||||
sharp().resize(0x4000, 240);
|
||||
});
|
||||
}, /Expected integer between 1 and 16383 for width but received 16384 of type number/);
|
||||
});
|
||||
|
||||
it('Invalid height - too large', function () {
|
||||
assert.throws(function () {
|
||||
sharp().resize(320, 0x4000);
|
||||
});
|
||||
}, /Expected integer between 1 and 16383 for height but received 16384 of type number/);
|
||||
});
|
||||
|
||||
it('WebP shrink-on-load rounds to zero, ensure recalculation is correct', function (done) {
|
||||
|
||||
Reference in New Issue
Block a user