Skip to content

Commit

Permalink
tests; execute correct binary
Browse files Browse the repository at this point in the history
  • Loading branch information
aheckmann committed Sep 21, 2022
1 parent fc526c3 commit fd6c720
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 26 deletions.
4 changes: 2 additions & 2 deletions test/crop.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require('assert')
const path = require('path');

module.exports = function (gm, dir, finish, GM) {
module.exports = function (gm, dir, finish, GM, imageMagick) {
const m = gm.crop(200, 155, 300, 0);

const args = m.args();
Expand All @@ -10,7 +10,7 @@ module.exports = function (gm, dir, finish, GM) {
assert.equal('200x155+300+0', args[3]);

const imagePath = path.join(dir, 'image.png');
const m2 = GM(imagePath).crop(200, 155, 300, 0, true);
const m2 = GM(imagePath).options({ imageMagick }).crop(200, 155, 300, 0, true);

const args2 = m2.args();
assert.equal('200x155+300+0%', args2[3]);
Expand Down
10 changes: 5 additions & 5 deletions test/dispose.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require('assert')
const path = require('path');

module.exports = function (img, dir, finish, gm) {
module.exports = function (img, dir, finish, gm, imageMagick) {
var EventEmitter = require('events').EventEmitter;
EventEmitter.prototype._maxListeners = 100;

Expand All @@ -15,10 +15,10 @@ module.exports = function (img, dir, finish, gm) {
events: ['pleaseDispose', 'readyToDispose']
};

var g = gm('test').options({ disposers: [ disposer ] });
var g = gm('test').options({ disposers: [ disposer ], imageMagick });
assert.deepEqual([disposer], g._options.disposers);

var sub = gm.subClass({ disposers: [ disposer ]});
var sub = gm.subClass({ disposers: [ disposer ], imageMagick });
assert.deepEqual([disposer], sub.prototype._options.disposers);

if (!gm.integration) {
Expand All @@ -28,7 +28,7 @@ module.exports = function (img, dir, finish, gm) {
const photoPath = path.join(dir, 'photo.JPG');
const disposePath = path.join(dir, 'dispose.png');

gm(photoPath).options({ disposers: [ disposer ]})
gm(photoPath).options({ disposers: [ disposer ], imageMagick })
.thumb(1000, 1000, disposePath, function (err) {
assert.ok(err, "Expecting a disposed error");
});
Expand All @@ -38,7 +38,7 @@ module.exports = function (img, dir, finish, gm) {
noDispose();

function noDispose() {
gm(photoPath).options({ disposers: [ disposer ]})
gm(photoPath).options({ disposers: [ disposer ], imageMagick })
.thumb(1000, 1000, disposePath, function (err) {
finish(err);
});
Expand Down
6 changes: 3 additions & 3 deletions test/flatten.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const assert = require('assert');
const path = require('path');

module.exports = function (img, dir, finish, gm) {
module.exports = function (_, dir, finish, gm, imageMagick) {
// graphicsmagick considers PSD broken
// http://www.graphicsmagick.org/NEWS.html#may-30-2016
if (!img._options.imageMagick) {
if (!imageMagick) {
return finish();
}

const layersPath = path.join(dir, 'layers.psd');
var m = gm(layersPath)
.options({ imageMagick: true })
.options({ imageMagick })
.flatten();

var args = m.args();
Expand Down
12 changes: 5 additions & 7 deletions test/fromBuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ const assert = require('assert');
const path = require('path');
const fs = require('fs')

module.exports = function (_, dir, finish, gm) {
module.exports = function (_, dir, finish, gm, imageMagick) {

const original = path.join(dir, 'original.jpg');
const result = path.join(dir, 'fromBuffer.png');

var buf = fs.readFileSync(original);

var m = gm(buf)
.rotate('red', 30);
var m = gm(buf).options({imageMagick}).rotate('red', 30);

var args = m.args();
assert.equal('convert', args[0]);
Expand All @@ -23,17 +22,16 @@ module.exports = function (_, dir, finish, gm) {
if (!gm.integration)
return finish();

m
.write(result, function crop (err) {
m.write(result, function crop (err) {
if (err) return finish(err);

// tolerance defaults to 0.4
gm.compare(original, result, function (err, equal) {
m.compare(original, result, function (err, equal) {
if (err) return finish(err);
assert.ok(equal);

// accepts tolerance argument
gm.compare(original, result, 0.1, function (err, equal, equality, raw) {
m.compare(original, result, 0.1, function (err, equal, equality, raw) {
if (err) return finish(err);
assert.ok(!equal);
assert.ok(equality > 0.1);
Expand Down
8 changes: 4 additions & 4 deletions test/geometry.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

var assert = require('assert')

module.exports = function (gm, dir, finish, GM) {
var a = GM("dummy").geometry("asdf"); // Custom geometry command
module.exports = function (_, __, finish, GM, imageMagick) {
var a = GM("dummy").options({imageMagick}).geometry("asdf"); // Custom geometry command
var args = a.args();
assert.equal('-geometry', args[2]);
assert.equal('asdf', args[3]);

var b = GM("dummy").geometry("", 100)
var b = GM("dummy").options({imageMagick}).geometry("", 100);
var args = b.args();
assert.equal('-geometry', args[2]);
assert.equal('x100', args[3]); // Keep-aspect-ratio command

return finish();
return finish();
}
4 changes: 2 additions & 2 deletions test/getterColor.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const assert = require('assert');
const path = require('path');

module.exports = function (_, dir, finish, gm) {
module.exports = function (_, dir, finish, gm, imageMagick) {
if (!gm.integration)
return finish();

const destPath = path.join(dir, 'blue.gif');
gm(destPath).color(function (err, color) {
gm(destPath).options({imageMagick}).color(function (err, color) {
if (err) return finish(err);

assert.equal(1, color)
Expand Down
4 changes: 2 additions & 2 deletions test/getterFormatGIF.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const assert = require('assert');
const path = require('path');

module.exports = function (_, dir, finish, gm) {
module.exports = function (_, dir, finish, gm, imageMagick) {
if (!gm.integration)
return finish();

const destPath = path.join(dir, 'original.gif');
gm(destPath)
gm(destPath).options({imageMagick})
.format(function (err, type) {
if (err) return finish(err);

Expand Down
2 changes: 1 addition & 1 deletion test/strip.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function (gm, dir, finish, GM) {
return finish();

const destPath = path.join(dir, 'strip.png');
m.write(destPath, function edge (err) {
m.write(destPath, function strip (err) {
finish(err);
});
}

0 comments on commit fd6c720

Please sign in to comment.