mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
more socket user tests
This commit is contained in:
48
test/user.js
48
test/user.js
@@ -610,7 +610,55 @@ describe('User', function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('socket methods', function () {
|
||||
var socketUser = require('../src/socket.io/user');
|
||||
|
||||
it('should fail with invalid data', function (done) {
|
||||
socketUser.exists({uid: testUid}, null, function (err) {
|
||||
assert.equal(err.message, '[[error:invalid-data]]');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return true if user/group exists', function (done) {
|
||||
socketUser.exists({uid: testUid}, {username: 'registered-users'}, function (err, exists) {
|
||||
assert.ifError(err);
|
||||
assert(exists);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return true if user/group exists', function (done) {
|
||||
socketUser.exists({uid: testUid}, {username: 'John Smith'}, function (err, exists) {
|
||||
assert.ifError(err);
|
||||
assert(exists);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return false if user/group does not exists', function (done) {
|
||||
socketUser.exists({uid: testUid}, {username: 'doesnot exist'}, function (err, exists) {
|
||||
assert.ifError(err);
|
||||
assert(!exists);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete user', function (done) {
|
||||
User.create({username: 'tobedeleted'}, function (err, _uid) {
|
||||
assert.ifError(err);
|
||||
socketUser.deleteAccount({uid: _uid}, {}, function (err) {
|
||||
assert.ifError(err);
|
||||
socketUser.exists({uid: testUid}, {username: 'doesnot exist'}, function (err, exists) {
|
||||
assert.ifError(err);
|
||||
assert(!exists);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user