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,17 +15,19 @@ describe('Counters', function () {
});
describe('increment', function () {
it('increments the current value by one', async function () {
await this.counter.increment();
expect(await this.counter.current()).to.be.bignumber.equal('1');
});
context('starting from 0', function () {
it('increments the current value by one', async function () {
await this.counter.increment();
expect(await this.counter.current()).to.be.bignumber.equal('1');
});
it('can be called multiple times', async function () {
await this.counter.increment();
await this.counter.increment();
await this.counter.increment();
it('can be called multiple times', async function () {
await this.counter.increment();
await this.counter.increment();
await this.counter.increment();
expect(await this.counter.current()).to.be.bignumber.equal('3');
expect(await this.counter.current()).to.be.bignumber.equal('3');
});
});
});
@ -34,28 +36,30 @@ describe('Counters', function () {
await this.counter.increment();
expect(await this.counter.current()).to.be.bignumber.equal('1');
});
context('starting from 1', function () {
it('decrements the current value by one', async function () {
await this.counter.decrement();
expect(await this.counter.current()).to.be.bignumber.equal('0');
});
it('decrements the current value by one', async function () {
await this.counter.decrement();
expect(await this.counter.current()).to.be.bignumber.equal('0');
it('reverts if the current value is 0', async function () {
await this.counter.decrement();
await expectRevert(this.counter.decrement(), 'SafeMath: subtraction overflow');
});
});
context('after incremented to 3', function () {
it('can be called multiple times', async function () {
await this.counter.increment();
await this.counter.increment();
it('reverts if the current value is 0', async function () {
await this.counter.decrement();
await expectRevert(this.counter.decrement(), 'SafeMath: subtraction overflow');
});
expect(await this.counter.current()).to.be.bignumber.equal('3');
it('can be called multiple times', async function () {
await this.counter.increment();
await this.counter.increment();
await this.counter.decrement();
await this.counter.decrement();
await this.counter.decrement();
expect(await this.counter.current()).to.be.bignumber.equal('3');
await this.counter.decrement();
await this.counter.decrement();
await this.counter.decrement();
expect(await this.counter.current()).to.be.bignumber.equal('0');
expect(await this.counter.current()).to.be.bignumber.equal('0');
});
});
});
});