Prefer const in test files (#1117)

* Removed all instances of var.

* Sorted eslintrc rules.

* Made eslint rule severity explicit.

* Now prefering const over let.
This commit is contained in:
Nicolás Venturo
2018-07-26 13:25:10 -03:00
committed by GitHub
parent 6e19ed47be
commit 567b773242
31 changed files with 171 additions and 176 deletions

View File

@ -14,16 +14,16 @@ contract('Destructible', function (accounts) {
});
it('should send balance to owner after destruction', async function () {
let initBalance = await ethGetBalance(this.owner);
const initBalance = await ethGetBalance(this.owner);
await this.destructible.destroy({ from: this.owner });
let newBalance = await ethGetBalance(this.owner);
const newBalance = await ethGetBalance(this.owner);
assert.isTrue(newBalance > initBalance);
});
it('should send balance to recepient after destruction', async function () {
let initBalance = await ethGetBalance(accounts[1]);
const initBalance = await ethGetBalance(accounts[1]);
await this.destructible.destroyAndSend(accounts[1], { from: this.owner });
let newBalance = await ethGetBalance(accounts[1]);
const newBalance = await ethGetBalance(accounts[1]);
assert.isTrue(newBalance.greaterThan(initBalance));
});
});

View File

@ -7,21 +7,21 @@ contract('Pausable', function (accounts) {
});
it('can perform normal process in non-pause', async function () {
let count0 = await this.Pausable.count();
const count0 = await this.Pausable.count();
assert.equal(count0, 0);
await this.Pausable.normalProcess();
let count1 = await this.Pausable.count();
const count1 = await this.Pausable.count();
assert.equal(count1, 1);
});
it('can not perform normal process in pause', async function () {
await this.Pausable.pause();
let count0 = await this.Pausable.count();
const count0 = await this.Pausable.count();
assert.equal(count0, 0);
await assertRevert(this.Pausable.normalProcess());
let count1 = await this.Pausable.count();
const count1 = await this.Pausable.count();
assert.equal(count1, 0);
});
@ -34,7 +34,7 @@ contract('Pausable', function (accounts) {
it('can take a drastic measure in a pause', async function () {
await this.Pausable.pause();
await this.Pausable.drasticMeasure();
let drasticMeasureTaken = await this.Pausable.drasticMeasureTaken();
const drasticMeasureTaken = await this.Pausable.drasticMeasureTaken();
assert.isTrue(drasticMeasureTaken);
});
@ -43,7 +43,7 @@ contract('Pausable', function (accounts) {
await this.Pausable.pause();
await this.Pausable.unpause();
await this.Pausable.normalProcess();
let count0 = await this.Pausable.count();
const count0 = await this.Pausable.count();
assert.equal(count0, 1);
});

View File

@ -1,37 +1,39 @@
const { ethGetBalance } = require('../helpers/web3');
var TokenDestructible = artifacts.require('TokenDestructible');
var StandardTokenMock = artifacts.require('StandardTokenMock');
const TokenDestructible = artifacts.require('TokenDestructible');
const StandardTokenMock = artifacts.require('StandardTokenMock');
contract('TokenDestructible', function (accounts) {
let destructible;
let tokenDestructible;
let owner;
beforeEach(async function () {
destructible = await TokenDestructible.new({
tokenDestructible = await TokenDestructible.new({
from: accounts[0],
value: web3.toWei('10', 'ether'),
});
owner = await destructible.owner();
owner = await tokenDestructible.owner();
});
it('should send balance to owner after destruction', async function () {
let initBalance = await ethGetBalance(owner);
await destructible.destroy([], { from: owner });
let newBalance = await ethGetBalance(owner);
const initBalance = await ethGetBalance(owner);
await tokenDestructible.destroy([], { from: owner });
const newBalance = await ethGetBalance(owner);
assert.isTrue(newBalance > initBalance);
});
it('should send tokens to owner after destruction', async function () {
let token = await StandardTokenMock.new(destructible.address, 100);
let initContractBalance = await token.balanceOf(destructible.address);
let initOwnerBalance = await token.balanceOf(owner);
const token = await StandardTokenMock.new(tokenDestructible.address, 100);
const initContractBalance = await token.balanceOf(tokenDestructible.address);
const initOwnerBalance = await token.balanceOf(owner);
assert.equal(initContractBalance, 100);
assert.equal(initOwnerBalance, 0);
await destructible.destroy([token.address], { from: owner });
let newContractBalance = await token.balanceOf(destructible.address);
let newOwnerBalance = await token.balanceOf(owner);
await tokenDestructible.destroy([token.address], { from: owner });
const newContractBalance = await token.balanceOf(tokenDestructible.address);
const newOwnerBalance = await token.balanceOf(owner);
assert.equal(newContractBalance, 0);
assert.equal(newOwnerBalance, 100);
});