Replace all asserts with chai.should (#1183)

* Moving towards chai.should.

* Fixed failing tests.

* Fixed linter errors.

* Revert package-lock.json changes.

* Fixed failing tests.

* s/eq/equal

* Addressed review comment
This commit is contained in:
Nicolás Venturo
2018-08-10 19:03:04 -03:00
committed by Francisco Giordano
parent a2e7103869
commit ac91af9a6a
41 changed files with 396 additions and 297 deletions

View File

@ -1,40 +1,48 @@
const { decodeLogs } = require('../helpers/decodeLogs');
const SimpleToken = artifacts.require('SimpleToken');
const BigNumber = web3.BigNumber;
require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
contract('SimpleToken', function ([_, creator]) {
let token;
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
beforeEach(async function () {
token = await SimpleToken.new({ from: creator });
});
it('has a name', async function () {
const name = await token.name();
assert.equal(name, 'SimpleToken');
name.should.eq('SimpleToken');
});
it('has a symbol', async function () {
const symbol = await token.symbol();
assert.equal(symbol, 'SIM');
symbol.should.eq('SIM');
});
it('has 18 decimals', async function () {
const decimals = await token.decimals();
assert(decimals.eq(18));
decimals.should.be.bignumber.equal(18);
});
it('assigns the initial total supply to the creator', async function () {
const totalSupply = await token.totalSupply();
const creatorBalance = await token.balanceOf(creator);
assert(creatorBalance.eq(totalSupply));
creatorBalance.should.be.bignumber.equal(totalSupply);
const receipt = await web3.eth.getTransactionReceipt(token.transactionHash);
const logs = decodeLogs(receipt.logs, SimpleToken, token.address);
assert.equal(logs.length, 1);
assert.equal(logs[0].event, 'Transfer');
assert.equal(logs[0].args.from.valueOf(), 0x0);
assert.equal(logs[0].args.to.valueOf(), creator);
assert(logs[0].args.value.eq(totalSupply));
logs.length.should.eq(1);
logs[0].event.should.equal('Transfer');
logs[0].args.from.valueOf().should.equal(ZERO_ADDRESS);
logs[0].args.to.valueOf().should.equal(creator);
logs[0].args.value.should.be.bignumber.equal(totalSupply);
});
});