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,16 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var fixtures = require('../fixtures');
|
||||
var sharp = require('../../index');
|
||||
const assert = require('assert');
|
||||
const fixtures = require('../fixtures');
|
||||
const sharp = require('../../index');
|
||||
|
||||
describe('Alpha transparency', function() {
|
||||
|
||||
it('Flatten to black', function(done) {
|
||||
describe('Alpha transparency', function () {
|
||||
it('Flatten to black', function (done) {
|
||||
sharp(fixtures.inputPngWithTransparency)
|
||||
.flatten()
|
||||
.resize(400, 300)
|
||||
.toBuffer(function(err, data, info) {
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(400, info.width);
|
||||
assert.strictEqual(300, info.height);
|
||||
@@ -18,12 +17,12 @@ describe('Alpha transparency', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('Flatten to RGB orange', function(done) {
|
||||
it('Flatten to RGB orange', function (done) {
|
||||
sharp(fixtures.inputPngWithTransparency)
|
||||
.flatten()
|
||||
.background({r: 255, g: 102, b: 0})
|
||||
.resize(400, 300)
|
||||
.toBuffer(function(err, data, info) {
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(400, info.width);
|
||||
assert.strictEqual(300, info.height);
|
||||
@@ -31,12 +30,12 @@ describe('Alpha transparency', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('Flatten to CSS/hex orange', function(done) {
|
||||
it('Flatten to CSS/hex orange', function (done) {
|
||||
sharp(fixtures.inputPngWithTransparency)
|
||||
.flatten()
|
||||
.background('#ff6600')
|
||||
.resize(400, 300)
|
||||
.toBuffer(function(err, data, info) {
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(400, info.width);
|
||||
assert.strictEqual(300, info.height);
|
||||
@@ -44,12 +43,12 @@ describe('Alpha transparency', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('Flatten 16-bit PNG with transparency to orange', function(done) {
|
||||
var output = fixtures.path('output.flatten-rgb16-orange.jpg');
|
||||
it('Flatten 16-bit PNG with transparency to orange', function (done) {
|
||||
const output = fixtures.path('output.flatten-rgb16-orange.jpg');
|
||||
sharp(fixtures.inputPngWithTransparency16bit)
|
||||
.flatten()
|
||||
.background({r: 255, g: 102, b: 0})
|
||||
.toFile(output, function(err, info) {
|
||||
.toFile(output, function (err, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, info.size > 0);
|
||||
assert.strictEqual(32, info.width);
|
||||
@@ -59,10 +58,10 @@ describe('Alpha transparency', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('Do not flatten', function(done) {
|
||||
it('Do not flatten', function (done) {
|
||||
sharp(fixtures.inputPngWithTransparency)
|
||||
.flatten(false)
|
||||
.toBuffer(function(err, data, info) {
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(4, info.channels);
|
||||
@@ -70,11 +69,11 @@ describe('Alpha transparency', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('Ignored for JPEG', function(done) {
|
||||
it('Ignored for JPEG', function (done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.background('#ff0000')
|
||||
.flatten()
|
||||
.toBuffer(function(err, data, info) {
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(3, info.channels);
|
||||
@@ -82,13 +81,13 @@ describe('Alpha transparency', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('Enlargement with non-nearest neighbor interpolation shouldn’t cause dark edges', function(done) {
|
||||
var BASE_NAME = 'alpha-premultiply-enlargement-2048x1536-paper.png';
|
||||
var actual = fixtures.path('output.' + BASE_NAME);
|
||||
var expected = fixtures.expected(BASE_NAME);
|
||||
it('Enlargement with non-nearest neighbor interpolation shouldn’t cause dark edges', function (done) {
|
||||
const base = 'alpha-premultiply-enlargement-2048x1536-paper.png';
|
||||
const actual = fixtures.path('output.' + base);
|
||||
const expected = fixtures.expected(base);
|
||||
sharp(fixtures.inputPngAlphaPremultiplicationSmall)
|
||||
.resize(2048, 1536)
|
||||
.toFile(actual, function(err) {
|
||||
.toFile(actual, function (err) {
|
||||
if (err) {
|
||||
done(err);
|
||||
} else {
|
||||
@@ -98,13 +97,13 @@ describe('Alpha transparency', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('Reduction with non-nearest neighbor interpolation shouldn’t cause dark edges', function(done) {
|
||||
var BASE_NAME = 'alpha-premultiply-reduction-1024x768-paper.png';
|
||||
var actual = fixtures.path('output.' + BASE_NAME);
|
||||
var expected = fixtures.expected(BASE_NAME);
|
||||
it('Reduction with non-nearest neighbor interpolation shouldn’t cause dark edges', function (done) {
|
||||
const base = 'alpha-premultiply-reduction-1024x768-paper.png';
|
||||
const actual = fixtures.path('output.' + base);
|
||||
const expected = fixtures.expected(base);
|
||||
sharp(fixtures.inputPngAlphaPremultiplicationLarge)
|
||||
.resize(1024, 768)
|
||||
.toFile(actual, function(err) {
|
||||
.toFile(actual, function (err) {
|
||||
if (err) {
|
||||
done(err);
|
||||
} else {
|
||||
@@ -113,5 +112,4 @@ describe('Alpha transparency', function() {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user