Improve error messages for invalid resize parameters

Dependency version bumps and doc refresh
This commit is contained in:
Lovell Fuller
2017-01-05 22:16:59 +00:00
parent 4858ebe051
commit 70a3d4fb5e
15 changed files with 182 additions and 76 deletions

View File

@@ -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 () {

View File

@@ -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) {