fix test and image normalize test

v1.18.x
Baris Usakli 8 years ago
parent 081ac6535c
commit 11d9410229

@ -117,7 +117,7 @@ function getUserData(req, next, callback) {
function (data, next) {
userData = data;
if (!userData) {
return callback();
return callback(null, null);
}
db.getObjectField('user:' + userData.uid, 'password', next);
},

@ -88,14 +88,16 @@ image.normalise = function (path, extension, callback) {
callback(err, path + '.png');
});
} else {
new Jimp(path, function (err, image) {
if (err) {
return callback(err);
}
image.write(path + '.png', function (err) {
callback(err, path + '.png');
});
});
async.waterfall([
function (next) {
new Jimp(path, next);
},
function (image, next) {
image.write(path + '.png', function (err) {
next(err, path + '.png');
});
},
], callback);
}
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

@ -0,0 +1,23 @@
'use strict';
var assert = require('assert');
var path = require('path');
var db = require('./mocks/databasemock');
var image = require('../src/image');
var file = require('../src/file');
describe('image', function () {
it('should normalise image', function (done) {
image.normalise(path.join(__dirname, 'files/normalise.jpg'), '.jpg', function (err) {
assert.ifError(err);
file.exists(path.join(__dirname, 'files/normalise.jpg.png'), function (err, exists) {
assert.ifError(err);
assert(exists);
done();
});
});
});
});
Loading…
Cancel
Save