mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Update tests to meet semistandard code standards
Switch to const/let instead of var
This commit is contained in:
@@ -1,105 +1,110 @@
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
const assert = require('assert');
|
||||
|
||||
var sharp = require('../../index');
|
||||
var fixtures = require('../fixtures');
|
||||
const sharp = require('../../index');
|
||||
const fixtures = require('../fixtures');
|
||||
|
||||
describe('Negate', function() {
|
||||
it('negate (jpeg)', function(done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320, 240)
|
||||
.negate()
|
||||
.toBuffer(function(err, data, info) {
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('negate.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
describe('Negate', function () {
|
||||
it('negate (jpeg)', function (done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320, 240)
|
||||
.negate()
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('negate.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('negate (png)', function(done) {
|
||||
sharp(fixtures.inputPng)
|
||||
.resize(320, 240)
|
||||
.negate()
|
||||
.toBuffer(function(err, data, info) {
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('negate.png'), data, done);
|
||||
});
|
||||
});
|
||||
it('negate (png)', function (done) {
|
||||
sharp(fixtures.inputPng)
|
||||
.resize(320, 240)
|
||||
.negate()
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('negate.png'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('negate (png, trans)', function(done) {
|
||||
sharp(fixtures.inputPngWithTransparency)
|
||||
.resize(320, 240)
|
||||
.negate()
|
||||
.toBuffer(function(err, data, info) {
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('negate-trans.png'), data, done);
|
||||
});
|
||||
});
|
||||
it('negate (png, trans)', function (done) {
|
||||
sharp(fixtures.inputPngWithTransparency)
|
||||
.resize(320, 240)
|
||||
.negate()
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('negate-trans.png'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('negate (png, alpha)', function(done) {
|
||||
sharp(fixtures.inputPngWithGreyAlpha)
|
||||
.resize(320, 240)
|
||||
.negate()
|
||||
.toBuffer(function(err, data, info) {
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('negate-alpha.png'), data, done);
|
||||
});
|
||||
});
|
||||
it('negate (png, alpha)', function (done) {
|
||||
sharp(fixtures.inputPngWithGreyAlpha)
|
||||
.resize(320, 240)
|
||||
.negate()
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('negate-alpha.png'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
if (sharp.format.webp.output.file) {
|
||||
it('negate (webp)', function(done) {
|
||||
sharp(fixtures.inputWebP)
|
||||
.resize(320, 240)
|
||||
.negate()
|
||||
.toBuffer(function(err, data, info) {
|
||||
assert.strictEqual('webp', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('negate.webp'), data, done);
|
||||
});
|
||||
});
|
||||
it('negate (webp)', function (done) {
|
||||
sharp(fixtures.inputWebP)
|
||||
.resize(320, 240)
|
||||
.negate()
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('webp', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('negate.webp'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('negate (webp, trans)', function(done) {
|
||||
sharp(fixtures.inputWebPWithTransparency)
|
||||
.resize(320, 240)
|
||||
.negate()
|
||||
.toBuffer(function(err, data, info) {
|
||||
assert.strictEqual('webp', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('negate-trans.webp'), data, done);
|
||||
});
|
||||
});
|
||||
}
|
||||
it('negate (webp, trans)', function (done) {
|
||||
sharp(fixtures.inputWebPWithTransparency)
|
||||
.resize(320, 240)
|
||||
.negate()
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('webp', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('negate-trans.webp'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('negate (true)', function(done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320, 240)
|
||||
.negate(true)
|
||||
.toBuffer(function(err, data, info) {
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('negate.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
it('negate (true)', function (done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320, 240)
|
||||
.negate(true)
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('negate.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('negate (false)', function(done) {
|
||||
var output = fixtures.path('output.unmodified-by-negate.png');
|
||||
sharp(fixtures.inputJpgWithLowContrast)
|
||||
.negate(false)
|
||||
.toFile(output, function(err, info) {
|
||||
if (err) done(err);
|
||||
fixtures.assertMaxColourDistance(output, fixtures.inputJpgWithLowContrast, 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('negate (false)', function (done) {
|
||||
const output = fixtures.path('output.unmodified-by-negate.png');
|
||||
sharp(fixtures.inputJpgWithLowContrast)
|
||||
.negate(false)
|
||||
.toFile(output, function (err, info) {
|
||||
if (err) throw err;
|
||||
fixtures.assertMaxColourDistance(output, fixtures.inputJpgWithLowContrast, 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user