step 9: test canVote()

This commit is contained in:
Pascal Precht 2019-01-29 12:48:23 +01:00
parent 0915ce8ede
commit e0d53e26cb
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D

View File

@ -30,4 +30,14 @@ contract('DReddit', () => {
assert.equal(web3.utils.toAscii(post.description), ipfsHash);
assert.equal(post.owner, accounts[0]);
});
it("should not be able to vote in an unexisting post", async () => {
const userCanVote = await DReddit.methods.canVote("123").call();
assert.equal(userCanVote, false);
});
it("should be able to vote in a post if account hasn't voted before", async () => {
const userCanVote = await DReddit.methods.canVote(postId).call();
assert.equal(userCanVote, true);
});
});