mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Drop support for versions of Node prior to v4.
Reduce production (sub)depedency count from 93 to 50. Modernise dev tooling, e.g. use nyc, replace jshint with semistandard. Make 'npm test' command consistent across platforms.
This commit is contained in:
@@ -1,19 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var fs = require('fs');
|
||||
var sharp = require('../../index');
|
||||
var fixtures = require('../fixtures');
|
||||
var BluebirdPromise = require('bluebird');
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
|
||||
describe('Image channel insertion', function() {
|
||||
const sharp = require('../../index');
|
||||
const fixtures = require('../fixtures');
|
||||
|
||||
it('Grayscale to RGB, buffer', function(done) {
|
||||
describe('Image channel insertion', function () {
|
||||
it('Grayscale to RGB, buffer', function (done) {
|
||||
sharp(fixtures.inputPng) // gray -> red
|
||||
.resize(320, 240)
|
||||
.joinChannel(fixtures.inputPngTestJoinChannel) // new green channel
|
||||
.joinChannel(fixtures.inputPngStripesH) // new blue channel
|
||||
.toBuffer(function(err, data, info) {
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
@@ -22,12 +21,12 @@ describe('Image channel insertion', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('Grayscale to RGB, file', function(done) {
|
||||
it('Grayscale to RGB, file', function (done) {
|
||||
sharp(fixtures.inputPng) // gray -> red
|
||||
.resize(320, 240)
|
||||
.joinChannel(fs.readFileSync(fixtures.inputPngTestJoinChannel)) // new green channel
|
||||
.joinChannel(fs.readFileSync(fixtures.inputPngStripesH)) // new blue channel
|
||||
.toBuffer(function(err, data, info) {
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
@@ -36,14 +35,14 @@ describe('Image channel insertion', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('Grayscale to RGBA, buffer', function(done) {
|
||||
it('Grayscale to RGBA, buffer', function (done) {
|
||||
sharp(fixtures.inputPng) // gray -> red
|
||||
.resize(320, 240)
|
||||
.joinChannel([fixtures.inputPngTestJoinChannel,
|
||||
fixtures.inputPngStripesH,
|
||||
fixtures.inputPngStripesV]) // new green + blue + alpha channel
|
||||
.toColourspace(sharp.colourspace.srgb)
|
||||
.toBuffer(function(err, data, info) {
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
@@ -52,14 +51,14 @@ describe('Image channel insertion', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('Grayscale to RGBA, file', function(done) {
|
||||
it('Grayscale to RGBA, file', function (done) {
|
||||
sharp(fixtures.inputPng) // gray -> red
|
||||
.resize(320, 240)
|
||||
.joinChannel([fs.readFileSync(fixtures.inputPngTestJoinChannel), // new green channel
|
||||
fs.readFileSync(fixtures.inputPngStripesH), // new blue channel
|
||||
fs.readFileSync(fixtures.inputPngStripesV)]) // new alpha channel
|
||||
.toColourspace('srgb')
|
||||
.toBuffer(function(err, data, info) {
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
@@ -68,7 +67,7 @@ describe('Image channel insertion', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('Grayscale to CMYK, buffers', function(done) {
|
||||
it('Grayscale to CMYK, buffers', function (done) {
|
||||
sharp(fixtures.inputPng) // gray -> magenta
|
||||
.resize(320, 240)
|
||||
.joinChannel([fs.readFileSync(fixtures.inputPngTestJoinChannel), // new cyan channel
|
||||
@@ -76,7 +75,7 @@ describe('Image channel insertion', function() {
|
||||
fs.readFileSync(fixtures.inputPngStripesV)]) // new black channel
|
||||
.toColorspace('cmyk')
|
||||
.toFormat('jpeg')
|
||||
.toBuffer(function(err, data, info) {
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
@@ -85,12 +84,12 @@ describe('Image channel insertion', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('Join raw buffers to RGB', function(done) {
|
||||
BluebirdPromise.all([
|
||||
it('Join raw buffers to RGB', function (done) {
|
||||
Promise.all([
|
||||
sharp(fixtures.inputPngTestJoinChannel).toColourspace('b-w').raw().toBuffer(),
|
||||
sharp(fixtures.inputPngStripesH).toColourspace('b-w').raw().toBuffer()
|
||||
])
|
||||
.then(function(buffers) {
|
||||
.then(function (buffers) {
|
||||
sharp(fixtures.inputPng)
|
||||
.resize(320, 240)
|
||||
.joinChannel(buffers,
|
||||
@@ -99,7 +98,7 @@ describe('Image channel insertion', function() {
|
||||
height: 240,
|
||||
channels: 1
|
||||
}})
|
||||
.toBuffer(function(err, data, info) {
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
@@ -107,19 +106,19 @@ describe('Image channel insertion', function() {
|
||||
fixtures.assertSimilar(fixtures.expected('joinChannel-rgb.jpg'), data, done);
|
||||
});
|
||||
})
|
||||
.catch(function(err) {
|
||||
.catch(function (err) {
|
||||
throw err;
|
||||
});
|
||||
});
|
||||
|
||||
it('Grayscale to RGBA, files, two arrays', function(done) {
|
||||
it('Grayscale to RGBA, files, two arrays', function (done) {
|
||||
sharp(fixtures.inputPng) // gray -> red
|
||||
.resize(320, 240)
|
||||
.joinChannel([fs.readFileSync(fixtures.inputPngTestJoinChannel)]) // new green channel
|
||||
.joinChannel([fs.readFileSync(fixtures.inputPngStripesH), // new blue channel
|
||||
fs.readFileSync(fixtures.inputPngStripesV)]) // new alpha channel
|
||||
.toColourspace('srgb')
|
||||
.toBuffer(function(err, data, info) {
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
@@ -128,24 +127,23 @@ describe('Image channel insertion', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('Invalid raw buffer description', function() {
|
||||
assert.throws(function() {
|
||||
sharp().joinChannel(fs.readFileSync(fixtures.inputPng),{raw:{}});
|
||||
it('Invalid raw buffer description', function () {
|
||||
assert.throws(function () {
|
||||
sharp().joinChannel(fs.readFileSync(fixtures.inputPng), {raw: {}});
|
||||
});
|
||||
});
|
||||
|
||||
it('Invalid input', function() {
|
||||
assert.throws(function() {
|
||||
it('Invalid input', function () {
|
||||
assert.throws(function () {
|
||||
sharp(fixtures.inputJpg)
|
||||
.joinChannel(1);
|
||||
});
|
||||
});
|
||||
|
||||
it('No arguments', function() {
|
||||
assert.throws(function() {
|
||||
it('No arguments', function () {
|
||||
assert.throws(function () {
|
||||
sharp(fixtures.inputJpg)
|
||||
.joinChannel();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user