diff --git a/test/controllers.js b/test/controllers.js index 8b01551773..1f73d4a7ae 100644 --- a/test/controllers.js +++ b/test/controllers.js @@ -596,7 +596,7 @@ describe('Controllers', function () { user.create({ username: 'revokeme', password: 'barbar' }, function (err, _uid) { assert.ifError(err); uid = _uid; - helpers.loginUser('revokeme', 'barbar', function (err, _jar, io, _csrf_token) { + helpers.loginUser('revokeme', 'barbar', function (err, _jar, _csrf_token) { assert.ifError(err); jar = _jar; csrf_token = _csrf_token; diff --git a/test/groups.js b/test/groups.js index ceba296c61..e914953e10 100644 --- a/test/groups.js +++ b/test/groups.js @@ -1138,7 +1138,7 @@ describe('Groups', function () { }); it('should error if user is not owner of group', function (done) { - helpers.loginUser('regularuser', '123456', function (err, jar, io, csrf_token) { + helpers.loginUser('regularuser', '123456', function (err, jar, csrf_token) { assert.ifError(err); helpers.uploadFile(nconf.get('url') + '/api/groups/uploadpicture', logoPath, { params: JSON.stringify({ groupName: 'Test' }) }, jar, csrf_token, function (err, res, body) { assert.ifError(err); @@ -1150,7 +1150,7 @@ describe('Groups', function () { }); it('should upload group cover with api route', function (done) { - helpers.loginUser('admin', '123456', function (err, jar, io, csrf_token) { + helpers.loginUser('admin', '123456', function (err, jar, csrf_token) { assert.ifError(err); helpers.uploadFile(nconf.get('url') + '/api/groups/uploadpicture', logoPath, { params: JSON.stringify({ groupName: 'Test' }) }, jar, csrf_token, function (err, res, body) { assert.ifError(err); diff --git a/test/helpers/index.js b/test/helpers/index.js index c589c7cdd5..e1274d5931 100644 --- a/test/helpers/index.js +++ b/test/helpers/index.js @@ -36,9 +36,7 @@ helpers.loginUser = function (username, password, callback) { if (err || res.statusCode !== 200) { return callback(err || new Error('[[error:invalid-response]]')); } - helpers.connectSocketIO(res, function (err, io) { - callback(err, jar, io, body.csrf_token); - }); + callback(null, jar, body.csrf_token); }); }); }; diff --git a/test/logger.js b/test/logger.js deleted file mode 100644 index 6dbdc5f547..0000000000 --- a/test/logger.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; - -/* global require, after, before*/ - -var assert = require('assert'); -var path = require('path'); -var fs = require('fs'); - -var db = require('./mocks/databasemock'); -var logger = require('../src/logger'); -var index = require('../src/socket.io'); -var meta = require('../src/meta'); -var user = require('../src/user'); -var helpers = require('./helpers'); - -describe('logger', function () { - var jar; - var io; - before(function (done) { - user.create({ username: 'loggeruser', password: '123456' }, function (err) { - assert.ifError(err); - helpers.loginUser('loggeruser', '123456', function (err, _jar, _io) { - assert.ifError(err); - jar = _jar; - io = _io; - done(); - }); - }); - }); - - it('should enable logging', function (done) { - meta.config.loggerStatus = 1; - meta.config.loggerIOStatus = 1; - var loggerPath = path.join(__dirname, '..', 'logs', 'logger.log'); - logger.monitorConfig({ io: index.server }, { key: 'loggerPath', value: loggerPath }); - setTimeout(function () { - io.emit('meta.rooms.enter', { enter: 'recent_topics' }, function (err) { - assert.ifError(err); - fs.readFile(loggerPath, 'utf-8', function (err, content) { - assert.ifError(err); - assert(content); - done(); - }); - }); - }, 500); - }); - - after(function (done) { - meta.config.loggerStatus = 0; - meta.config.loggerIOStatus = 0; - done(); - }); -}); diff --git a/test/socket.io.js b/test/socket.io.js index 52d8ebc1fe..547895f970 100644 --- a/test/socket.io.js +++ b/test/socket.io.js @@ -576,7 +576,7 @@ describe('socket.io', function () { }); }); - it('shoudl delete all events', function (done) { + it('should delete all events', function (done) { socketAdmin.deleteAllEvents({ uid: adminUid }, {}, function (err) { assert.ifError(err); db.sortedSetCard('events:time', function (err, count) { @@ -586,5 +586,34 @@ describe('socket.io', function () { }); }); }); -}); + describe('logger', function () { + var logger = require('../src/logger'); + var index = require('../src/socket.io'); + var fs = require('fs'); + var path = require('path'); + + it('should enable logging', function (done) { + meta.config.loggerStatus = 1; + meta.config.loggerIOStatus = 1; + var loggerPath = path.join(__dirname, '..', 'logs', 'logger.log'); + logger.monitorConfig({ io: index.server }, { key: 'loggerPath', value: loggerPath }); + setTimeout(function () { + io.emit('meta.rooms.enter', { enter: 'recent_topics' }, function (err) { + assert.ifError(err); + fs.readFile(loggerPath, 'utf-8', function (err, content) { + assert.ifError(err); + assert(content); + done(); + }); + }); + }, 500); + }); + + after(function (done) { + meta.config.loggerStatus = 0; + meta.config.loggerIOStatus = 0; + done(); + }); + }); +}); diff --git a/test/uploads.js b/test/uploads.js index ca8e3b1bea..959662e9b0 100644 --- a/test/uploads.js +++ b/test/uploads.js @@ -57,7 +57,7 @@ describe('Upload Controllers', function () { var csrf_token; before(function (done) { - helpers.loginUser('regular', 'zugzug', function (err, _jar, io, _csrf_token) { + helpers.loginUser('regular', 'zugzug', function (err, _jar, _csrf_token) { assert.ifError(err); jar = _jar; csrf_token = _csrf_token; @@ -155,7 +155,7 @@ describe('Upload Controllers', function () { var csrf_token; before(function (done) { - helpers.loginUser('admin', 'barbar', function (err, _jar, io, _csrf_token) { + helpers.loginUser('admin', 'barbar', function (err, _jar, _csrf_token) { assert.ifError(err); jar = _jar; csrf_token = _csrf_token; diff --git a/test/user.js b/test/user.js index 428a0fc038..417424a033 100644 --- a/test/user.js +++ b/test/user.js @@ -454,12 +454,10 @@ describe('User', function () { }); describe('not logged in', function () { - var jar; var io; before(function (done) { helpers.initSocketIO(function (err, _jar, _io) { assert.ifError(err); - jar = _jar; io = _io; done(); }); @@ -476,30 +474,28 @@ describe('User', function () { describe('profile methods', function () { var uid; var jar; - var io; before(function (done) { User.create({ username: 'updateprofile', email: 'update@me.com', password: '123456' }, function (err, newUid) { assert.ifError(err); uid = newUid; - helpers.loginUser('updateprofile', '123456', function (err, _jar, _io) { + helpers.loginUser('updateprofile', '123456', function (err, _jar) { assert.ifError(err); jar = _jar; - io = _io; done(); }); }); }); it('should return error if data is invalid', function (done) { - io.emit('user.updateProfile', null, function (err) { + socketUser.updateProfile({ uid: uid }, null, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); }); it('should return error if data is missing uid', function (done) { - io.emit('user.updateProfile', { username: 'bip', email: 'bop' }, function (err) { + socketUser.updateProfile({ uid: uid }, { username: 'bip', email: 'bop' }, function (err) { assert.equal(err.message, '[[error:invalid-data]]'); done(); }); @@ -517,7 +513,7 @@ describe('User', function () { birthday: '01/01/1980', signature: 'nodebb is good', }; - io.emit('user.updateProfile', data, function (err, result) { + socketUser.updateProfile({ uid: uid }, data, function (err, result) { assert.ifError(err); assert.equal(result.username, 'updatedUserName'); @@ -549,7 +545,7 @@ describe('User', function () { }); it('should change username', function (done) { - io.emit('user.changeUsernameEmail', { uid: uid, username: 'updatedAgain', password: '123456' }, function (err) { + socketUser.changeUsernameEmail({ uid: uid }, { uid: uid, username: 'updatedAgain', password: '123456' }, function (err) { assert.ifError(err); db.getObjectField('user:' + uid, 'username', function (err, username) { assert.ifError(err); @@ -560,7 +556,7 @@ describe('User', function () { }); it('should change email', function (done) { - io.emit('user.changeUsernameEmail', { uid: uid, email: 'updatedAgain@me.com', password: '123456' }, function (err) { + socketUser.changeUsernameEmail({ uid: uid }, { uid: uid, email: 'updatedAgain@me.com', password: '123456' }, function (err) { assert.ifError(err); db.getObjectField('user:' + uid, 'email', function (err, email) { assert.ifError(err); @@ -573,7 +569,7 @@ describe('User', function () { it('should update cover image', function (done) { var imageData = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAgCAYAAAABtRhCAAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2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/Orqqnv69OmoZVn/mEwm/9TzvP9x138NAMpJ4VFTBr6SAAAAAElFTkSuQmCC'; var position = '50.0301% 19.2464%'; - io.emit('user.updateCover', { uid: uid, imageData: imageData, position: position }, function (err, result) { + socketUser.updateCover({ uid: uid }, { uid: uid, imageData: imageData, position: position }, function (err, result) { assert.ifError(err); assert(result.url); db.getObjectFields('user:' + uid, ['cover:url', 'cover:position'], function (err, data) { @@ -600,7 +596,7 @@ describe('User', function () { }); it('should remove cover image', function (done) { - io.emit('user.removeCover', { uid: uid }, function (err) { + socketUser.removeCover({ uid: uid }, { uid: uid }, function (err) { assert.ifError(err); db.getObjectField('user:' + uid, 'cover:url', function (err, url) { assert.ifError(err); @@ -611,7 +607,7 @@ describe('User', function () { }); it('should set user status', function (done) { - io.emit('user.setStatus', 'away', function (err, data) { + socketUser.setStatus({ uid: uid }, 'away', function (err, data) { assert.ifError(err); assert.equal(data.uid, uid); assert.equal(data.status, 'away'); @@ -620,14 +616,14 @@ describe('User', function () { }); it('should fail for invalid status', function (done) { - io.emit('user.setStatus', '12345', function (err) { + socketUser.setStatus({ uid: uid }, '12345', function (err) { assert.equal(err.message, '[[error:invalid-user-status]]'); done(); }); }); it('should get user status', function (done) { - io.emit('user.checkStatus', uid, function (err, status) { + socketUser.checkStatus({ uid: uid }, uid, function (err, status) { assert.ifError(err); assert.equal(status, 'away'); done(); @@ -635,7 +631,7 @@ describe('User', function () { }); it('should change user picture', function (done) { - io.emit('user.changePicture', { type: 'default', uid: uid }, function (err) { + socketUser.changePicture({ uid: uid }, { type: 'default', uid: uid }, function (err) { assert.ifError(err); User.getUserField(uid, 'picture', function (err, picture) { assert.ifError(err); @@ -802,7 +798,7 @@ describe('User', function () { }); it('should get profile pictures', function (done) { - io.emit('user.getProfilePictures', { uid: uid }, function (err, data) { + socketUser.getProfilePictures({ uid: uid }, { uid: uid }, function (err, data) { assert.ifError(err); assert(data); assert(Array.isArray(data)); @@ -835,7 +831,7 @@ describe('User', function () { }); it('should remove uploaded picture', function (done) { - io.emit('user.removeUploadedPicture', { uid: uid }, function (err) { + socketUser.removeUploadedPicture({ uid: uid }, { uid: uid }, function (err) { assert.ifError(err); User.getUserField(uid, 'uploadedpicture', function (err, uploadedpicture) { assert.ifError(err);