mirror of
https://github.com/wassname/talk.git
synced 2026-07-24 13:20:47 +08:00
Updated test to verify middleware is working
This commit is contained in:
@@ -42,7 +42,7 @@ router.post('/', wordlist.filter('body'), (req, res, next) => {
|
||||
})
|
||||
.then((comment) => {
|
||||
|
||||
res.status(200).send(comment);
|
||||
res.status(201).send(comment);
|
||||
})
|
||||
.catch((err) => {
|
||||
next(err);
|
||||
|
||||
@@ -10,6 +10,7 @@ const expect = chai.expect;
|
||||
chai.should();
|
||||
chai.use(require('chai-http'));
|
||||
|
||||
const wordlist = require('../../../../services/wordlist');
|
||||
const Comment = require('../../../../models/comment');
|
||||
const Action = require('../../../../models/action');
|
||||
const User = require('../../../../models/user');
|
||||
@@ -184,12 +185,15 @@ describe('Post /comments', () => {
|
||||
beforeEach(() => {
|
||||
return Promise.all([
|
||||
User.createLocalUsers(users),
|
||||
Action.create(actions)
|
||||
Action.create(actions),
|
||||
wordlist.insert([
|
||||
'bad words'
|
||||
])
|
||||
]);
|
||||
});
|
||||
|
||||
it('it should create a comment', () => {
|
||||
chai.request(app)
|
||||
it('should create a comment', () => {
|
||||
return chai.request(app)
|
||||
.post('/api/v1/comments')
|
||||
.send({'body': 'Something body.', 'author_id': '123', 'asset_id': '1', 'parent_id': ''})
|
||||
.then((res) => {
|
||||
@@ -197,6 +201,17 @@ describe('Post /comments', () => {
|
||||
expect(res.body).to.have.property('id');
|
||||
});
|
||||
});
|
||||
|
||||
it('should create a comment with a rejected status if it contains a bad word', () => {
|
||||
return chai.request(app)
|
||||
.post('/api/v1/comments')
|
||||
.send({'body': 'bad words are the baddest', 'author_id': '123', 'asset_id': '1', 'parent_id': ''})
|
||||
.then((res) => {
|
||||
expect(res).to.have.status(201);
|
||||
expect(res.body).to.have.property('id');
|
||||
expect(res.body).to.have.property('status', 'rejected');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Get /:comment_id', () => {
|
||||
|
||||
Reference in New Issue
Block a user