Add 'animated' constructor property as shortcut for 'pages'

Provides easier-to-understand API when handling animated images
This commit is contained in:
Lovell Fuller
2020-08-18 20:28:25 +01:00
parent b711661784
commit 4beae0de71
5 changed files with 28 additions and 0 deletions

View File

@@ -649,6 +649,15 @@ describe('Input/output', function () {
sharp({ density: 'zoinks' });
}, /Expected number between 1 and 2400 for density but received zoinks of type string/);
});
it('Setting animated property updates pages property', function () {
assert.strictEqual(sharp({ animated: false }).options.input.pages, 1);
assert.strictEqual(sharp({ animated: true }).options.input.pages, -1);
});
it('Invalid animated property throws', function () {
assert.throws(function () {
sharp({ animated: -1 });
}, /Expected boolean for animated but received -1 of type number/);
});
it('Invalid page property throws', function () {
assert.throws(function () {
sharp({ page: -1 });