Files
openzeppelin-contracts/test/examples/SimpleToken.test.js
Nicolás Venturo c2de8ffd14 Now testing events in constructors! (#1511)
* Added inTransaction tests.

* Added expectEvent.inConstructor.

* Changed inTransaction, removed decodeLogs.

* Flipped comparison to improve the error message.

* Improved expectEvent tests.

* Migrated tests to use expectEvent.

* Added roles constructor tests.

* Fixed linter errors.

* Made lodash a dev dependency.

* Added more inLogs tests.

* Update expectEvent.test.js

* Removed lodash.

* Moved role constructor tests to public role behavior.

* Revert "Flipped comparison to improve the error message."

This reverts commit 438c57833d.

* Replaced chai-as-promised with shouldFail.
2018-11-27 17:56:26 -03:00

41 lines
1.1 KiB
JavaScript

const expectEvent = require('../helpers/expectEvent');
const { ZERO_ADDRESS } = require('../helpers/constants');
const SimpleToken = artifacts.require('SimpleToken');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
contract('SimpleToken', function ([_, creator]) {
beforeEach(async function () {
this.token = await SimpleToken.new({ from: creator });
});
it('has a name', async function () {
(await this.token.name()).should.equal('SimpleToken');
});
it('has a symbol', async function () {
(await this.token.symbol()).should.equal('SIM');
});
it('has 18 decimals', async function () {
(await this.token.decimals()).should.be.bignumber.equal(18);
});
it('assigns the initial total supply to the creator', async function () {
const totalSupply = await this.token.totalSupply();
const creatorBalance = await this.token.balanceOf(creator);
creatorBalance.should.be.bignumber.equal(totalSupply);
await expectEvent.inConstruction(this.token, 'Transfer', {
from: ZERO_ADDRESS,
to: creator,
value: totalSupply,
});
});
});