From e0d53e26cb14a67d4347a9f875dfdb6356435fa0 Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Tue, 29 Jan 2019 12:48:23 +0100 Subject: [PATCH] step 9: test canVote() --- test/DReddit_spec.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/DReddit_spec.js b/test/DReddit_spec.js index 76a7570..9f339e3 100644 --- a/test/DReddit_spec.js +++ b/test/DReddit_spec.js @@ -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); + }); });