Allow instance reuse with differing toBuffer options (#1860)

This commit is contained in:
Raboliot le gris
2019-09-08 15:35:16 +02:00
committed by Lovell Fuller
parent 69fe21a7ec
commit fb5c393fbd
3 changed files with 22 additions and 0 deletions

19
test/unit/toBuffer.js Normal file
View File

@@ -0,0 +1,19 @@
'use strict';
const assert = require('assert');
const sharp = require('../../');
const fixtures = require('../fixtures');
describe('toBuffer', () => {
it('reusing same sharp object does not reset previously passed parameters to toBuffer', (done) => {
let image = sharp(fixtures.inputJpg);
image.toBuffer({ resolveWithObject: true }).then((obj) => {
image.toBuffer().then((buff) => {
assert.strict.equal(Buffer.isBuffer(buff), true);
assert.strict.equal(typeof obj, 'object');
done();
});
});
});
});