mirror of
https://github.com/wassname/talk.git
synced 2026-09-12 13:01:11 +08:00
Move the change status of the user to a ban the user func.
This commit is contained in:
+48
-1
@@ -1,6 +1,7 @@
|
||||
require('../utils/mongoose');
|
||||
|
||||
const User = require('../../models/user');
|
||||
const Comment = require('../../models/comment');
|
||||
const expect = require('chai').expect;
|
||||
|
||||
describe('User: models', () => {
|
||||
@@ -65,9 +66,43 @@ describe('User: models', () => {
|
||||
});
|
||||
|
||||
describe('#setStatus', () => {
|
||||
it('should set the status to active', () => {
|
||||
return User
|
||||
.setStatus(mockUsers[0].id, 'active')
|
||||
.then(() => {
|
||||
User.findById(mockUsers[0].id)
|
||||
.then((user) => {
|
||||
expect(user).to.have.property('status')
|
||||
.and.to.equal('active');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#ban', () => {
|
||||
let mockComment;
|
||||
beforeEach(() => {
|
||||
return Comment.new('testing the comment for that user if it is rejected.', mockUsers[0].id)
|
||||
.then((comment) => {
|
||||
mockComment = comment;
|
||||
});
|
||||
});
|
||||
|
||||
it('should disable the user', () => {
|
||||
return User
|
||||
.ban(mockUsers[0].id, mockComment.id)
|
||||
.then(() => {
|
||||
User.findById(mockUsers[0].id)
|
||||
.then((user) => {
|
||||
expect(user).to.have.property('disabled')
|
||||
.and.to.equal(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should set the status to banned', () => {
|
||||
return User
|
||||
.setStatus(mockUsers[0].id, 'banned')
|
||||
.ban(mockUsers[0].id, mockComment.id)
|
||||
.then(() => {
|
||||
User.findById(mockUsers[0].id)
|
||||
.then((user) => {
|
||||
@@ -76,5 +111,17 @@ describe('User: models', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should set the comment to rejected', () => {
|
||||
return User
|
||||
.ban(mockUsers[0].id, mockComment.id)
|
||||
.then(() => {
|
||||
Comment.findById(mockComment.id)
|
||||
.then((comment) => {
|
||||
expect(comment).to.have.property('status')
|
||||
.and.to.equal('rejected');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user