Skip to content

Commit

Permalink
tests; cleanup compare test
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanong committed Aug 31, 2013
1 parent d21d6bf commit f2b8428
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions test/compare.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,29 @@ var assert = require('assert');
var fs = require('fs');

module.exports = function (gm, dir, finish, GM) {
// Same image
GM.compare(dir + '/original.jpg', dir + '/original.png', function(err, same) {
if (err || !same) finish(err);
else outputDiff();
});
if (err) return finish(err);
if (!same) return finish(new Error('Compare should be the same!'));

function outputDiff() {
var options = {
highlightColor: 'yellow',
file: dir + '/diff.png'
};
GM.compare(dir + '/original.jpg', dir + '/noise1.png', options, function(err) {
// Create a new noisy image
gm.noise(0.3).write(dir + '/noise3.png', function (err) {
if (err) return finish(err);
fs.exists(options.file, function(exists) {
finish(!exists);

var options = {
highlightColor: 'yellow',
file: dir + '/diff.png'
};

// Compare these images and write to a file.
GM.compare(dir + '/original.jpg', dir + '/noise3.png', options, function(err) {
if (err) return finish(err);

fs.exists(options.file, function(exists) {
if (exists) finish();
else finish(new Error('Diff file does not exist.'));
});
});
});
}
})
});
};

0 comments on commit f2b8428

Please sign in to comment.