Add ComentsService#removeTag

This commit is contained in:
Benjamin Goering
2017-02-28 19:59:33 +08:00
parent 1bb20923a2
commit 4ff6bce8ec
2 changed files with 55 additions and 3 deletions
+16 -2
View File
@@ -251,15 +251,29 @@ describe('services.CommentsService', () => {
});
describe('#removeTag', () => {
it.skip('removes a tag', async () => {
it('removes a tag', async () => {
const commentId = comments[0].id;
const tagName = 'BEST';
await CommentsService.addTag(commentId, tagName, users[0].id);
let updatedComment = await CommentsService.findById(commentId);
const updatedComment = await CommentsService.findById(commentId);
expect(updatedComment.tags.length).to.equal(1);
// ok now to remove it
await CommentsService.removeTag(commentId, tagName);
const updatedComment2 = await CommentsService.findById(commentId);
expect(updatedComment2.tags.length).to.equal(0);
});
it('throws if removing a tag that isn\'t there', async () => {
const commentId = comments[0].id;
// just make sure it has no tags to start
const updatedComment2 = await CommentsService.findById(commentId);
expect(updatedComment2.tags.length).to.equal(0);
const tagName = 'BEST';
// ok now to remove it
await expect(CommentsService.removeTag(commentId, tagName)).to.be.rejected;
});
});