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,20 +1,19 @@
|
||||
'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('Colour space conversion', function() {
|
||||
|
||||
it('To greyscale', function(done) {
|
||||
describe('Colour space conversion', function () {
|
||||
it('To greyscale', function (done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320, 240)
|
||||
.greyscale()
|
||||
.toFile(fixtures.path('output.greyscale-gamma-0.0.jpg'), done);
|
||||
});
|
||||
|
||||
it('To greyscale with gamma correction', function(done) {
|
||||
it('To greyscale with gamma correction', function (done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320, 240)
|
||||
.gamma()
|
||||
@@ -22,19 +21,19 @@ describe('Colour space conversion', function() {
|
||||
.toFile(fixtures.path('output.greyscale-gamma-2.2.jpg'), done);
|
||||
});
|
||||
|
||||
it('Not to greyscale', function(done) {
|
||||
it('Not to greyscale', function (done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320, 240)
|
||||
.greyscale(false)
|
||||
.toFile(fixtures.path('output.greyscale-not.jpg'), done);
|
||||
});
|
||||
|
||||
it('Greyscale with single channel output', function(done) {
|
||||
it('Greyscale with single channel output', function (done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320, 240)
|
||||
.greyscale()
|
||||
.toColourspace('b-w')
|
||||
.toBuffer(function(err, data, info) {
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(1, info.channels);
|
||||
assert.strictEqual(320, info.width);
|
||||
@@ -44,10 +43,10 @@ describe('Colour space conversion', function() {
|
||||
});
|
||||
|
||||
if (sharp.format.tiff.input.file && sharp.format.webp.output.buffer) {
|
||||
it('From 1-bit TIFF to sRGB WebP [slow]', function(done) {
|
||||
it('From 1-bit TIFF to sRGB WebP [slow]', function (done) {
|
||||
sharp(fixtures.inputTiff)
|
||||
.webp()
|
||||
.toBuffer(function(err, data, info) {
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, data.length > 0);
|
||||
assert.strictEqual('webp', info.format);
|
||||
@@ -56,10 +55,10 @@ describe('Colour space conversion', function() {
|
||||
});
|
||||
}
|
||||
|
||||
it('From CMYK to sRGB', function(done) {
|
||||
it('From CMYK to sRGB', function (done) {
|
||||
sharp(fixtures.inputJpgWithCmykProfile)
|
||||
.resize(320)
|
||||
.toBuffer(function(err, data, info) {
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, data.length > 0);
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
@@ -68,12 +67,12 @@ describe('Colour space conversion', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('From CMYK to sRGB with white background, not yellow', function(done) {
|
||||
it('From CMYK to sRGB with white background, not yellow', function (done) {
|
||||
sharp(fixtures.inputJpgWithCmykProfile)
|
||||
.resize(320, 240)
|
||||
.background('white')
|
||||
.embed()
|
||||
.toBuffer(function(err, data, info) {
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
@@ -82,10 +81,10 @@ describe('Colour space conversion', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('From profile-less CMYK to sRGB', function(done) {
|
||||
it('From profile-less CMYK to sRGB', function (done) {
|
||||
sharp(fixtures.inputJpgWithCmykNoProfile)
|
||||
.resize(320)
|
||||
.toBuffer(function(err, data, info) {
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
@@ -93,8 +92,8 @@ describe('Colour space conversion', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('Invalid input', function() {
|
||||
assert.throws(function() {
|
||||
it('Invalid input', function () {
|
||||
assert.throws(function () {
|
||||
sharp(fixtures.inputJpg)
|
||||
.toColourspace(null);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user