mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Ensure tests pass with latest libvips master branch
Expose forthcoming HEIF features where available
This commit is contained in:
@@ -18,7 +18,7 @@ describe('AVIF', () => {
|
||||
.toBuffer();
|
||||
const metadata = await sharp(data)
|
||||
.metadata();
|
||||
const { size, ...metadataWithoutSize } = metadata;
|
||||
const { compression, size, ...metadataWithoutSize } = metadata;
|
||||
assert.deepStrictEqual(metadataWithoutSize, {
|
||||
channels: 3,
|
||||
depth: 'uchar',
|
||||
@@ -42,7 +42,7 @@ describe('AVIF', () => {
|
||||
.toBuffer();
|
||||
const metadata = await sharp(data)
|
||||
.metadata();
|
||||
const { size, ...metadataWithoutSize } = metadata;
|
||||
const { compression, size, ...metadataWithoutSize } = metadata;
|
||||
assert.deepStrictEqual(metadataWithoutSize, {
|
||||
channels: 3,
|
||||
chromaSubsampling: '4:2:0',
|
||||
@@ -65,7 +65,7 @@ describe('AVIF', () => {
|
||||
.toBuffer();
|
||||
const metadata = await sharp(data)
|
||||
.metadata();
|
||||
const { size, ...metadataWithoutSize } = metadata;
|
||||
const { compression, size, ...metadataWithoutSize } = metadata;
|
||||
assert.deepStrictEqual(metadataWithoutSize, {
|
||||
channels: 3,
|
||||
depth: 'uchar',
|
||||
|
||||
@@ -53,7 +53,7 @@ describe('failOnError', function () {
|
||||
|
||||
it('returns errors to callback for truncated JPEG', function (done) {
|
||||
sharp(fixtures.inputJpgTruncated).toBuffer(function (err, data, info) {
|
||||
assert.ok(err.message.includes('VipsJpeg: Premature end of JPEG file'), err);
|
||||
assert.ok(err.message.includes('VipsJpeg: Premature end of'), err);
|
||||
assert.strictEqual(data, undefined);
|
||||
assert.strictEqual(info, undefined);
|
||||
done();
|
||||
@@ -76,7 +76,7 @@ describe('failOnError', function () {
|
||||
throw new Error('Expected rejection');
|
||||
})
|
||||
.catch(err => {
|
||||
done(err.message.includes('VipsJpeg: Premature end of JPEG file') ? undefined : err);
|
||||
done(err.message.includes('VipsJpeg: Premature end of') ? undefined : err);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -65,4 +65,14 @@ describe('HEIF', () => {
|
||||
sharp().heif({ compression: 'fail' });
|
||||
});
|
||||
});
|
||||
it('invalid chromaSubsampling should throw an error', () => {
|
||||
assert.throws(() => {
|
||||
sharp().heif({ chromaSubsampling: 'fail' });
|
||||
});
|
||||
});
|
||||
it('valid chromaSubsampling does not throw an error', () => {
|
||||
assert.doesNotThrow(() => {
|
||||
sharp().heif({ chromaSubsampling: '4:4:4' });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -667,7 +667,7 @@ describe('Image metadata', function () {
|
||||
sharp(fixtures.inputJpgWithCorruptHeader)
|
||||
.metadata(function (err) {
|
||||
assert.strictEqual(true, !!err);
|
||||
assert.strictEqual(true, /Input file has corrupt header: VipsJpeg: Premature end of JPEG file/.test(err.message));
|
||||
assert.ok(err.message.includes('Input file has corrupt header: VipsJpeg: Premature end of'), err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -676,7 +676,7 @@ describe('Image metadata', function () {
|
||||
sharp(fs.readFileSync(fixtures.inputJpgWithCorruptHeader))
|
||||
.metadata(function (err) {
|
||||
assert.strictEqual(true, !!err);
|
||||
assert.strictEqual(true, /Input buffer has corrupt header: VipsJpeg: Premature end of JPEG file/.test(err.message));
|
||||
assert.ok(err.message.includes('Input buffer has corrupt header: VipsJpeg: Premature end of'), err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user