Files
openzeppelin-contracts/test/drafts/Counters.test.js
Yohann Pereira 489d2e85f1 Replace chai.should with chai.expect (#1780)
* changed exxpect to expect wherever applicable

* Merged with latest branch

* Updated merkleTree helper to latest master branch

* Made linting fixes

* Fix for test build

* updated for Coverage

* Updated Address.test.js

* Undo package-lock changes.
2019-06-24 17:40:05 -03:00

61 lines
1.8 KiB
JavaScript

const { expectRevert } = require('openzeppelin-test-helpers');
const { expect } = require('chai');
const CountersImpl = artifacts.require('CountersImpl');
contract('Counters', function () {
beforeEach(async function () {
this.counter = await CountersImpl.new();
});
it('starts at zero', async function () {
expect(await this.counter.current()).to.be.bignumber.equal('0');
});
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');
});
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');
});
});
describe('decrement', function () {
beforeEach(async function () {
await this.counter.increment();
expect(await this.counter.current()).to.be.bignumber.equal('1');
});
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');
});
it('can be called multiple times', async function () {
await this.counter.increment();
await this.counter.increment();
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');
});
});
});