mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
fix test and image normalize test
This commit is contained in:
@@ -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);
|
||||
},
|
||||
|
||||
18
src/image.js
18
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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
BIN
test/files/normalise.jpg
Normal file
BIN
test/files/normalise.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
23
test/image.js
Normal file
23
test/image.js
Normal file
@@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user