mirror of
https://github.com/wassname/talk.git
synced 2026-07-16 11:22:16 +08:00
Improve test.
This commit is contained in:
@@ -27,7 +27,7 @@ router.post('/', (req, res, next) => {
|
||||
const {body, author_id, asset_id, parent_id, status} = req.body;
|
||||
let comment = new Comment({body, author_id, asset_id, parent_id, status});
|
||||
comment.save().then(({id}) => {
|
||||
res.status(200).send(id);
|
||||
res.status(200).send({'id': id});
|
||||
}).catch(error => {
|
||||
next(error);
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ const Comment = require('../../../../models/comment');
|
||||
const Action = require('../../../../models/action');
|
||||
const User = require('../../../../models/user');
|
||||
|
||||
describe('Get /:comment_id', () => {
|
||||
describe('Get /comments', () => {
|
||||
const comments = [{
|
||||
id: 'abc',
|
||||
body: 'comment 10',
|
||||
@@ -95,6 +95,7 @@ describe('Post /comments', () => {
|
||||
.send({'body': 'Something body.', 'author_id': '123', 'asset_id': '1', 'parent_id': ''})
|
||||
.end(function(err, res){
|
||||
expect(res).to.have.status(200);
|
||||
expect(res.body).to.have.property('id');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -148,7 +149,8 @@ describe('Get /:comment_id', () => {
|
||||
.end(function(err, res){
|
||||
expect(err).to.be.null;
|
||||
expect(res).to.have.status(200);
|
||||
if (err) {return done(err);}
|
||||
expect(res.body[0]).to.have.property('body');
|
||||
expect(res.body[0].body).to.equal('comment 10');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -201,7 +203,10 @@ describe('Put /:comment_id', () => {
|
||||
.post('/api/v1/comments/abc')
|
||||
.send({'body': 'Something body.', 'author_id': '123', 'asset_id': '1', 'parent_id': ''})
|
||||
.end(function(err, res){
|
||||
expect(err).to.be.null;
|
||||
expect(res).to.have.status(200);
|
||||
expect(res.body).to.have.property('body');
|
||||
expect(res.body.body).to.equal('Something body.');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -312,6 +317,8 @@ describe('Post /:comment_id/status', () => {
|
||||
expect(err).to.be.null;
|
||||
expect(res).to.have.status(200);
|
||||
expect(res).to.have.body;
|
||||
expect(res.body).to.have.property('status');
|
||||
expect(res.body.status).to.equal('accepted');
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -369,6 +376,15 @@ describe('Post /:comment_id/actions', () => {
|
||||
.end(function(err, res){
|
||||
expect(err).to.be.null;
|
||||
expect(res).to.have.status(200);
|
||||
expect(res).to.have.body;
|
||||
expect(res.body).to.have.property('item_type');
|
||||
expect(res.body.item_type).to.equal('comment');
|
||||
expect(res.body).to.have.property('action_type');
|
||||
expect(res.body.action_type).to.equal('flag');
|
||||
expect(res.body).to.have.property('item_id');
|
||||
expect(res.body.item_id).to.equal('abc');
|
||||
expect(res.body).to.have.property('user_id');
|
||||
expect(res.body.user_id).to.equal('456');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user