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,18 +1,17 @@
|
||||
'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('Extend', function () {
|
||||
|
||||
it('extend all sides equally with RGB', function(done) {
|
||||
it('extend all sides equally with RGB', function (done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(120)
|
||||
.background({r: 255, g: 0, b: 0})
|
||||
.extend(10)
|
||||
.toBuffer(function(err, data, info) {
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(140, info.width);
|
||||
assert.strictEqual(118, info.height);
|
||||
@@ -20,12 +19,12 @@ describe('Extend', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('extend sides unequally with RGBA', function(done) {
|
||||
it('extend sides unequally with RGBA', function (done) {
|
||||
sharp(fixtures.inputPngWithTransparency16bit)
|
||||
.resize(120)
|
||||
.background({r: 0, g: 0, b: 0, a: 0})
|
||||
.extend({top: 50, bottom: 0, left: 10, right: 35})
|
||||
.toBuffer(function(err, data, info) {
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(165, info.width);
|
||||
assert.strictEqual(170, info.height);
|
||||
@@ -33,32 +32,32 @@ describe('Extend', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('missing parameter fails', function() {
|
||||
assert.throws(function() {
|
||||
it('missing parameter fails', function () {
|
||||
assert.throws(function () {
|
||||
sharp().extend();
|
||||
});
|
||||
});
|
||||
it('negative fails', function() {
|
||||
assert.throws(function() {
|
||||
it('negative fails', function () {
|
||||
assert.throws(function () {
|
||||
sharp().extend(-1);
|
||||
});
|
||||
});
|
||||
it('partial object fails', function() {
|
||||
assert.throws(function() {
|
||||
it('partial object fails', function () {
|
||||
assert.throws(function () {
|
||||
sharp().extend({top: 1});
|
||||
});
|
||||
});
|
||||
|
||||
it('should add alpha channel before extending with a transparent Background', function( done ){
|
||||
it('should add alpha channel before extending with a transparent Background', function (done) {
|
||||
sharp(fixtures.inputJpgWithLandscapeExif1)
|
||||
.background({r: 0, g: 0, b: 0, a: 0})
|
||||
.toFormat( sharp.format.png )
|
||||
.toFormat(sharp.format.png)
|
||||
.extend({top: 0, bottom: 10, left: 0, right: 10})
|
||||
.toBuffer( function(err, data, info){
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(610, info.width);
|
||||
assert.strictEqual(460, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('addAlphaChanelBeforeExtend.png'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user