diff --git a/test/DReddit_spec.js b/test/DReddit_spec.js index 9f53588..a03db19 100644 --- a/test/DReddit_spec.js +++ b/test/DReddit_spec.js @@ -1,7 +1,23 @@ +const DReddit = embark.require('Embark/contracts/DReddit'); + +const ipfsHash = 'Qmc5gCcjYypU7y28oCALwfSvxCBskLuPKWpK4qpterKC7z'; + +config({ + contracts: { + DReddit: {} + } +}) contract('DReddit', () => { it('should work', () => { assert.ok(true); }); + + it('should be able to create a post and receive it via contract event', async () => { + let receipt = await DReddit.methods.createPost(web3.utils.fromAscii(ipfsHash)).send(); + const event = receipt.events.NewPost; + postId = event.returnValues.postId; + assert.equal(web3.utils.toAscii(event.returnValues.description), ipfsHash); + }); });