mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-26 01:09:56 +01:00
some more tests for #5232
This commit is contained in:
@@ -126,7 +126,9 @@ Flags.getTarget = function (type, id, uid, callback) {
|
||||
break;
|
||||
|
||||
case 'user':
|
||||
user.getUsersData(id, callback);
|
||||
user.getUsersData([id], function (err, users) {
|
||||
callback(err, users ? users[0] : undefined);
|
||||
});
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -101,6 +101,48 @@ describe('Flags', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('.getTarget()', function() {
|
||||
it('should return a post\'s data if queried with type "post"', function (done) {
|
||||
Flags.getTarget('post', 1, 1, function (err, data) {
|
||||
assert.ifError(err);
|
||||
var compare = {
|
||||
uid: 1,
|
||||
pid: 1,
|
||||
content: 'This is flaggable content'
|
||||
};
|
||||
|
||||
for(var key in compare) {
|
||||
if (compare.hasOwnProperty(key)) {
|
||||
assert.ok(data[key]);
|
||||
assert.strictEqual(data[key], compare[key]);
|
||||
}
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return a user\'s data if queried with type "user"', function (done) {
|
||||
Flags.getTarget('user', 1, 1, function (err, data) {
|
||||
assert.ifError(err);
|
||||
var compare = {
|
||||
uid: 1,
|
||||
username: 'testUser',
|
||||
email: 'b@c.com'
|
||||
};
|
||||
|
||||
for(var key in compare) {
|
||||
if (compare.hasOwnProperty(key)) {
|
||||
assert.ok(data[key]);
|
||||
assert.strictEqual(data[key], compare[key]);
|
||||
}
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});;
|
||||
|
||||
after(function (done) {
|
||||
db.emptydb(done);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user