Improve test descriptions #1157 (#2334)

Co-authored-by: Paolo Dibitonto <p.dibitonto@almaviva.it>
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
This commit is contained in:
dibi91
2020-08-25 19:58:45 +02:00
committed by GitHub
parent 1f06fd7e66
commit 0b489f4d79
16 changed files with 402 additions and 375 deletions

View File

@ -15,35 +15,39 @@ describe('PullPayment', function () {
this.contract = await PullPaymentMock.new({ value: amount });
});
it('can record an async payment correctly', async function () {
await this.contract.callTransfer(payee1, 100, { from: payer });
expect(await this.contract.payments(payee1)).to.be.bignumber.equal('100');
describe('payments', function () {
it('can record an async payment correctly', async function () {
await this.contract.callTransfer(payee1, 100, { from: payer });
expect(await this.contract.payments(payee1)).to.be.bignumber.equal('100');
});
it('can add multiple balances on one account', async function () {
await this.contract.callTransfer(payee1, 200, { from: payer });
await this.contract.callTransfer(payee1, 300, { from: payer });
expect(await this.contract.payments(payee1)).to.be.bignumber.equal('500');
});
it('can add balances on multiple accounts', async function () {
await this.contract.callTransfer(payee1, 200, { from: payer });
await this.contract.callTransfer(payee2, 300, { from: payer });
expect(await this.contract.payments(payee1)).to.be.bignumber.equal('200');
expect(await this.contract.payments(payee2)).to.be.bignumber.equal('300');
});
});
it('can add multiple balances on one account', async function () {
await this.contract.callTransfer(payee1, 200, { from: payer });
await this.contract.callTransfer(payee1, 300, { from: payer });
expect(await this.contract.payments(payee1)).to.be.bignumber.equal('500');
});
describe('withdrawPayments', function () {
it('can withdraw payment', async function () {
const balanceTracker = await balance.tracker(payee1);
it('can add balances on multiple accounts', async function () {
await this.contract.callTransfer(payee1, 200, { from: payer });
await this.contract.callTransfer(payee2, 300, { from: payer });
await this.contract.callTransfer(payee1, amount, { from: payer });
expect(await this.contract.payments(payee1)).to.be.bignumber.equal(amount);
expect(await this.contract.payments(payee1)).to.be.bignumber.equal('200');
await this.contract.withdrawPayments(payee1);
expect(await this.contract.payments(payee2)).to.be.bignumber.equal('300');
});
it('can withdraw payment', async function () {
const balanceTracker = await balance.tracker(payee1);
await this.contract.callTransfer(payee1, amount, { from: payer });
expect(await this.contract.payments(payee1)).to.be.bignumber.equal(amount);
await this.contract.withdrawPayments(payee1);
expect(await balanceTracker.delta()).to.be.bignumber.equal(amount);
expect(await this.contract.payments(payee1)).to.be.bignumber.equal('0');
expect(await balanceTracker.delta()).to.be.bignumber.equal(amount);
expect(await this.contract.payments(payee1)).to.be.bignumber.equal('0');
});
});
});