Ensure tests pass with latest libvips master branch

Expose forthcoming HEIF features where available
This commit is contained in:
Lovell Fuller
2021-01-13 16:47:49 +00:00
parent 138e60adb3
commit 8d49b7dde1
12 changed files with 50 additions and 9 deletions

View File

@@ -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',

View File

@@ -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);
});
});

View File

@@ -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' });
});
});
});

View File

@@ -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();
});
});