Skip to content

Commit

Permalink
resizeExact tests
Browse files Browse the repository at this point in the history
  • Loading branch information
drochag committed Jul 18, 2015
1 parent b1fbac5 commit c7e10ac
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions test/resizeWrong.js
Expand Up @@ -8,7 +8,7 @@ module.exports = function (_, dir, finish, gm) {
var original = dir + '/original.png';
var resized = dir + '/resize';
var widths = [300, 700, 400, 800, 200], i, cb;
var resize = function (width, index) {
var resizeExact = function (width, index) {
var name = resized + index + '.png';

if (index == widths.length) {
Expand All @@ -17,34 +17,22 @@ module.exports = function (_, dir, finish, gm) {
index++;
}
gm(original)
.resize(width)
.resizeExact(width)
.write(name, function(err){
if (err) return finish(err);

gm(name)
.size(function (err, size) {
if (err) return finish(err);
if (size.width !== width) {
gm(original)
.resizeExact(width)
.write(name, function (err) {
if (err) return finish(err);

gm(name)
.size(function (err, size) {
if (err) return finish(err);
if (size.width !== width) {
return finish("Wrong resizing on requested:" + width + ", resized:" + size.width);
}
});
});
return finish("Wrong resizing on requested:" + width + ", resized:" + size.width);
}

if (cb) return cb();
resize(widths[index], index);
resizeExact(widths[index], index);
});
});
};

resize(widths[0], 0);
resizeExact(widths[0], 0);
}

0 comments on commit c7e10ac

Please sign in to comment.