Updating tests for pending users endpoint.

This commit is contained in:
David Jay
2016-12-19 20:27:58 -05:00
parent 845d274b9b
commit 20505acfbe
2 changed files with 24 additions and 3 deletions
+1 -1
View File
@@ -450,7 +450,7 @@ UserService.setStatus = (id, status, comment_id) => {
});
}
if (status === 'active') {
if (status === 'active' || status === 'pending') {
return UserModel.update({
id: id
}, {
+23 -2
View File
@@ -59,6 +59,10 @@ describe('/api/v1/queue', () => {
action_type: 'like',
item_id: 'hij',
item_type: 'comment'
}, {
action_type: 'flag',
item_id: '123',
item_type: 'user'
}];
beforeEach(() => {
@@ -67,10 +71,14 @@ describe('/api/v1/queue', () => {
comments[0].author_id = u[0].id;
comments[1].author_id = u[1].id;
comments[2].author_id = u[1].id;
actions[2].item_id = u[1].id;
return Comment.create(comments);
return Promise.all([
Comment.create(comments),
...u.map((u) => User.setStatus(u.id, 'pending'))
]);
})
.then((c) => {
.then(([c]) => {
actions[0].item_id = c[0].id;
actions[1].item_id = c[1].id;
@@ -94,4 +102,17 @@ describe('/api/v1/queue', () => {
done();
});
});
it('should return all pending users and actions', function(done){
chai.request(app)
.get('/api/v1/queue/users/pending')
.set(passport.inject({roles: ['admin']}))
.end(function(err, res){
expect(err).to.be.null;
expect(res).to.have.status(200);
expect(res.body.users[0]).to.have.property('displayName');
expect(res.body.actions[0]).to.have.property('action_type');
done();
});
});
});