From fd6c72070d74a16d4846fdc0330e0dcfe4c82aad Mon Sep 17 00:00:00 2001 From: Aaron Heckmann Date: Tue, 20 Sep 2022 19:52:55 -0700 Subject: [PATCH] tests; execute correct binary --- test/crop.js | 4 ++-- test/dispose.js | 10 +++++----- test/flatten.js | 6 +++--- test/fromBuffer.js | 12 +++++------- test/geometry.js | 8 ++++---- test/getterColor.js | 4 ++-- test/getterFormatGIF.js | 4 ++-- test/strip.js | 2 +- 8 files changed, 24 insertions(+), 26 deletions(-) diff --git a/test/crop.js b/test/crop.js index ac11e455..07195eb5 100644 --- a/test/crop.js +++ b/test/crop.js @@ -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(); @@ -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]); diff --git a/test/dispose.js b/test/dispose.js index ec7cc726..67b9598b 100644 --- a/test/dispose.js +++ b/test/dispose.js @@ -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; @@ -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) { @@ -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"); }); @@ -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); }); diff --git a/test/flatten.js b/test/flatten.js index d093bd19..46e04c73 100644 --- a/test/flatten.js +++ b/test/flatten.js @@ -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(); diff --git a/test/fromBuffer.js b/test/fromBuffer.js index 1bb5d6db..c5ab2dc5 100644 --- a/test/fromBuffer.js +++ b/test/fromBuffer.js @@ -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]); @@ -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); diff --git a/test/geometry.js b/test/geometry.js index 4dbbbcdd..3df00f39 100644 --- a/test/geometry.js +++ b/test/geometry.js @@ -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(); } diff --git a/test/getterColor.js b/test/getterColor.js index 9f95a5a6..793f43fe 100644 --- a/test/getterColor.js +++ b/test/getterColor.js @@ -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) diff --git a/test/getterFormatGIF.js b/test/getterFormatGIF.js index 0fd6dafd..6a3fcb6f 100644 --- a/test/getterFormatGIF.js +++ b/test/getterFormatGIF.js @@ -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); diff --git a/test/strip.js b/test/strip.js index 7f7c0cb7..b4d3b700 100644 --- a/test/strip.js +++ b/test/strip.js @@ -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); }); }