Updated test to verify middleware is working

This commit is contained in:
Wyatt Johnson
2016-11-21 12:49:04 -07:00
parent cab9ec3e52
commit a45a5f7296
2 changed files with 19 additions and 4 deletions
+1 -1
View File
@@ -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);
+18 -3
View File
@@ -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', () => {