Skip to content

Commit

Permalink
补充删除comment的测试
Browse files Browse the repository at this point in the history
  • Loading branch information
keenwon committed Nov 7, 2017
1 parent 1cf7c6c commit c15b76d
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions test/modules/comment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,51 @@ class CommentTest {
return checkState && checkEntities;
});
}

@test async 'comment delete'() {
let newsId = Date.now();
let deleteCommentId = 1000001;

const comments = [
{
id: deleteCommentId,
content: 'comments 1',
author: {
id: 1006,
name: 'xiao hong',
email: 'xiaohong@example.com'
}
},
{
id: 1000002,
content: 'comments 2',
author: {
id: 1006,
name: 'xiao hong',
email: 'xiaohong@example.com'
}
}
];

// mock get commemts
mockFetch(comments);

// mock delete comment
mockFetch({
id: deleteCommentId
});

await store.dispatch('comment/getList', newsId);

return store
.dispatch('comment/delete', {newsId, commentId: deleteCommentId})
.then(() => {
let commentIds = [1000001, 1000002];

let checkState = store.state.comment.map[newsId].should.deep.equal([1000002]);
let checkEntities = store.getters['comment/list'](newsId).should.deep.equal([comments[1]]);

return checkState && checkEntities;
});
}
}

0 comments on commit c15b76d

Please sign in to comment.