Skip to content

Instantly share code, notes, and snippets.

@espoirMur
Created February 3, 2019 20:33
Show Gist options
  • Save espoirMur/66cf399d0d74e130ae43d151bc4bb944 to your computer and use it in GitHub Desktop.
Save espoirMur/66cf399d0d74e130ae43d151bc4bb944 to your computer and use it in GitHub Desktop.
Test for rating a given article
const canRate = done => {
request(app)
.post(`/api/v1/post/${post.id}/rating`)
.set('Authorization', `Bearer ${user.token}`)
.send({ userId: user.id, postId: post.id, rating: 4 })
.end((err, res) => {
expect(res.status).toBe(201);
expect(res.body.rating).toBeDefined();
ratingId = res.body.rating.id;
expect(res.body.message).toBe('Post rated successfully');
done();
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment