Allow use of toBuffer+toFile w/ same instance #3044

This commit is contained in:
Lovell Fuller
2022-02-03 22:01:46 +00:00
parent 2b01951306
commit 424660278d
3 changed files with 18 additions and 0 deletions

View File

@@ -328,6 +328,20 @@ describe('Input/output', function () {
});
});
it('Allow use of toBuffer and toFile with same instance', async () => {
const instance = sharp({
create: {
width: 8,
height: 8,
channels: 3,
background: 'red'
}
});
await instance.toFile(fixtures.path('output.jpg'));
const data = await instance.toBuffer();
assert.strictEqual(Buffer.isBuffer(data), true);
});
it('Fail when output File is input File', function (done) {
sharp(fixtures.inputJpg).toFile(fixtures.inputJpg, function (err) {
assert(err instanceof Error);