Created
March 13, 2019 13:42
-
-
Save mystere10/5a76934e568871ccf0e60f394295aaf8 to your computer and use it in GitHub Desktop.
Testing comment endpoint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import chai from 'chai'; | |
import chaiHttp from 'chai-http'; | |
const should = chai.should(); | |
chai.use(chaiHttp); | |
let clinentToken; | |
describe('Comment test', () => { | |
clinentToken = res.body.token; | |
it('should created a comment', (done) => { | |
const comment = { | |
id: '1', | |
createdAt: '2016-02-18T03:22:56.637Z', | |
updatedAt: '2016-02-18T03:22:56.637Z', | |
body: 'It takes a Jacobian', | |
author: { | |
username: 'jake', | |
bio: 'I work at statefarm', | |
image: 'https://i.stack.imgur.com/xHWG8.jpg', | |
following: false, | |
}, | |
}; | |
chai.request(server) | |
.post('/api/v1/:slug/comment') | |
.send(comment) | |
.set('Authorization', `Bearer, ${clinentToken}`) | |
.end((err, res) => { | |
res.should.have.status(201); | |
res.body.should.be.a('object'); | |
res.body.should.have.property('comment'); | |
res.body.comment.should.have.property('id').eql('1'); | |
res.body.comment.should.have.property('createdAt').eql('2016-02-18T03:22:56.637Z'); | |
res.body.comment.should.have.property('updatedAt').eql('2016-02-18T03:22:56.637Z'); | |
res.body.comment.body.should.be.a('object'); | |
res.body.comment.body.should.have.property('username').eql('It takes a Jacobian'); | |
res.body.comment.body.should.have.property('bio').eql('jake'); | |
res.body.comment.body.should.have.property('image').eql('I work at statefarm'); | |
res.body.comment.body.should.have.property('following').eql(false); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment