Skip to content
Permalink
Browse files

Test with more than one project

  • Loading branch information...
ilanolkies committed Mar 19, 2019
1 parent 2dfa7ae commit 0c10ccd97164b235243d58b43913e7388fefabd7
Showing with 41 additions and 0 deletions.
  1. +41 −0 test/direct_donate.js
@@ -77,4 +77,45 @@ contract('DirectDonate', async (accounts) => {

assert.equal(balance, previousBalance.toNumber() + value);
});

it('should store 3 projects and send founds to receivers', async () => {
const projects = [
{
name: 'KKL',
receiver: accounts[1],
url: 'https://kklweb.org'
},
{
name: 'unicef',
receiver: accounts[2],
url: 'https://unicef.org'
},
{
name: 'KKL',
receiver: accounts[3],
url: 'https://ymca.org'
}
];

for (const project of projects) await directDonate.addProject(project.name, project.receiver, project.url);

for (const i of [0, 1, 2]) {
const project = await directDonate.projects(i);

assert.equal(project[0], projects[i].name);
assert.equal(project[1], projects[i].receiver);
assert.equal(project[2], projects[i].url);

const getReceiverBalance = async () => await web3.eth.getBalance(projects[i].receiver);

const previousBalance = await getReceiverBalance();
const value = 1e18;

await directDonate.donate(i, { from: accounts[4], value });

const balance = await getReceiverBalance();

assert.equal(balance, previousBalance.toNumber() + value);
}
});
});

0 comments on commit 0c10ccd

Please sign in to comment.
You can’t perform that action at this time.