Node.js based forum software built for the modern web
fix test and image normalize test
Baris Usakli11d9410229fa
diff --git a/src/controllers/accounts/edit.js b/src/controllers/accounts/edit.jsindex 9fb9f7a501..cae91cf9d7 100644--- a/src/controllers/accounts/edit.js+++ b/src/controllers/accounts/edit.js@@ -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);},diff --git a/src/image.js b/src/image.jsindex 1609993731..9377757cf3 100644--- a/src/image.js+++ b/src/image.js@@ -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);}};diff --git a/test/files/normalise.jpg b/test/files/normalise.jpgnew file mode 100644index 0000000000..013a8d0cb2Binary files /dev/null and b/test/files/normalise.jpg differdiff --git a/test/image.js b/test/image.jsnew file mode 100644index 0000000000..3c7b0c6369--- /dev/null+++ b/test/image.js@@ -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();+ });+ });+ });++});