Skip to content

Commit 9fedfd9

Browse files
committed
done coverting should to expect
1 parent c5c52e4 commit 9fedfd9

16 files changed

+184
-152
lines changed

test/token/ERC20/ERC20.behavior.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
const { BN, constants, expectEvent, expectRevert } = require('openzeppelin-test-helpers');
22
const { ZERO_ADDRESS } = constants;
33

4+
const { expect } = require('chai');
5+
46
function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recipient, anotherAccount) {
57
describe('total supply', function () {
68
it('returns the total amount of tokens', async function () {
7-
(await this.token.totalSupply()).should.be.bignumber.equal(initialSupply);
9+
expect(await this.token.totalSupply()).to.be.bignumber.equal(initialSupply);
810
});
911
});
1012

1113
describe('balanceOf', function () {
1214
describe('when the requested account has no tokens', function () {
1315
it('returns zero', async function () {
14-
(await this.token.balanceOf(anotherAccount)).should.be.bignumber.equal('0');
16+
expect(await this.token.balanceOf(anotherAccount)).to.be.bignumber.equal('0');
1517
});
1618
});
1719

1820
describe('when the requested account has some tokens', function () {
1921
it('returns the total amount of tokens', async function () {
20-
(await this.token.balanceOf(initialHolder)).should.be.bignumber.equal(initialSupply);
22+
expect(await this.token.balanceOf(initialHolder)).to.be.bignumber.equal(initialSupply);
2123
});
2224
});
2325
});
@@ -50,15 +52,15 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip
5052
it('transfers the requested amount', async function () {
5153
await this.token.transferFrom(tokenOwner, to, amount, { from: spender });
5254

53-
(await this.token.balanceOf(tokenOwner)).should.be.bignumber.equal('0');
55+
expect(await this.token.balanceOf(tokenOwner)).to.be.bignumber.equal('0');
5456

55-
(await this.token.balanceOf(to)).should.be.bignumber.equal(amount);
57+
expect(await this.token.balanceOf(to)).to.be.bignumber.equal(amount);
5658
});
5759

5860
it('decreases the spender allowance', async function () {
5961
await this.token.transferFrom(tokenOwner, to, amount, { from: spender });
6062

61-
(await this.token.allowance(tokenOwner, spender)).should.be.bignumber.equal('0');
63+
expect(await this.token.allowance(tokenOwner, spender)).to.be.bignumber.equal('0');
6264
});
6365

6466
it('emits a transfer event', async function () {
@@ -176,9 +178,9 @@ function shouldBehaveLikeERC20Transfer (errorPrefix, from, to, balance, transfer
176178
it('transfers the requested amount', async function () {
177179
await transfer.call(this, from, to, amount);
178180

179-
(await this.token.balanceOf(from)).should.be.bignumber.equal('0');
181+
expect(await this.token.balanceOf(from)).to.be.bignumber.equal('0');
180182

181-
(await this.token.balanceOf(to)).should.be.bignumber.equal(amount);
183+
expect(await this.token.balanceOf(to)).to.be.bignumber.equal(amount);
182184
});
183185

184186
it('emits a transfer event', async function () {
@@ -198,9 +200,9 @@ function shouldBehaveLikeERC20Transfer (errorPrefix, from, to, balance, transfer
198200
it('transfers the requested amount', async function () {
199201
await transfer.call(this, from, to, amount);
200202

201-
(await this.token.balanceOf(from)).should.be.bignumber.equal(balance);
203+
expect(await this.token.balanceOf(from)).to.be.bignumber.equal(balance);
202204

203-
(await this.token.balanceOf(to)).should.be.bignumber.equal('0');
205+
expect(await this.token.balanceOf(to)).to.be.bignumber.equal('0');
204206
});
205207

206208
it('emits a transfer event', async function () {
@@ -243,7 +245,7 @@ function shouldBehaveLikeERC20Approve (errorPrefix, owner, spender, supply, appr
243245
it('approves the requested amount', async function () {
244246
await approve.call(this, owner, spender, amount);
245247

246-
(await this.token.allowance(owner, spender)).should.be.bignumber.equal(amount);
248+
expect(await this.token.allowance(owner, spender)).to.be.bignumber.equal(amount);
247249
});
248250
});
249251

@@ -255,7 +257,7 @@ function shouldBehaveLikeERC20Approve (errorPrefix, owner, spender, supply, appr
255257
it('approves the requested amount and replaces the previous one', async function () {
256258
await approve.call(this, owner, spender, amount);
257259

258-
(await this.token.allowance(owner, spender)).should.be.bignumber.equal(amount);
260+
expect(await this.token.allowance(owner, spender)).to.be.bignumber.equal(amount);
259261
});
260262
});
261263
});
@@ -277,7 +279,7 @@ function shouldBehaveLikeERC20Approve (errorPrefix, owner, spender, supply, appr
277279
it('approves the requested amount', async function () {
278280
await approve.call(this, owner, spender, amount);
279281

280-
(await this.token.allowance(owner, spender)).should.be.bignumber.equal(amount);
282+
expect(await this.token.allowance(owner, spender)).to.be.bignumber.equal(amount);
281283
});
282284
});
283285

@@ -289,7 +291,7 @@ function shouldBehaveLikeERC20Approve (errorPrefix, owner, spender, supply, appr
289291
it('approves the requested amount and replaces the previous one', async function () {
290292
await approve.call(this, owner, spender, amount);
291293

292-
(await this.token.allowance(owner, spender)).should.be.bignumber.equal(amount);
294+
expect(await this.token.allowance(owner, spender)).to.be.bignumber.equal(amount);
293295
});
294296
});
295297
});

test/token/ERC20/ERC20.test.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const { BN, constants, expectEvent, expectRevert } = require('openzeppelin-test-helpers');
22
const { ZERO_ADDRESS } = constants;
33

4+
const { expect } = require('chai');
5+
46
const {
57
shouldBehaveLikeERC20,
68
shouldBehaveLikeERC20Transfer,
@@ -51,12 +53,12 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) {
5153
it('decreases the spender allowance subtracting the requested amount', async function () {
5254
await this.token.decreaseAllowance(spender, approvedAmount.subn(1), { from: initialHolder });
5355

54-
(await this.token.allowance(initialHolder, spender)).should.be.bignumber.equal('1');
56+
expect(await this.token.allowance(initialHolder, spender)).to.be.bignumber.equal('1');
5557
});
5658

5759
it('sets the allowance to zero when all allowance is removed', async function () {
5860
await this.token.decreaseAllowance(spender, approvedAmount, { from: initialHolder });
59-
(await this.token.allowance(initialHolder, spender)).should.be.bignumber.equal('0');
61+
expect(await this.token.allowance(initialHolder, spender)).to.be.bignumber.equal('1');
6062
});
6163

6264
it('reverts when more than the full allowance is removed', async function () {
@@ -114,7 +116,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) {
114116
it('approves the requested amount', async function () {
115117
await this.token.increaseAllowance(spender, amount, { from: initialHolder });
116118

117-
(await this.token.allowance(initialHolder, spender)).should.be.bignumber.equal(amount);
119+
expect(await this.token.allowance(initialHolder, spender)).to.be.bignumber.equal(amount);
118120
});
119121
});
120122

@@ -126,7 +128,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) {
126128
it('increases the spender allowance adding the requested amount', async function () {
127129
await this.token.increaseAllowance(spender, amount, { from: initialHolder });
128130

129-
(await this.token.allowance(initialHolder, spender)).should.be.bignumber.equal(amount.addn(1));
131+
expect(await this.token.allowance(initialHolder, spender)).to.be.bignumber.equal(amount.addn(1));
130132
});
131133
});
132134
});
@@ -148,7 +150,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) {
148150
it('approves the requested amount', async function () {
149151
await this.token.increaseAllowance(spender, amount, { from: initialHolder });
150152

151-
(await this.token.allowance(initialHolder, spender)).should.be.bignumber.equal(amount);
153+
expect(await this.token.allowance(initialHolder, spender)).to.be.bignumber.equal(amount);
152154
});
153155
});
154156

@@ -160,7 +162,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) {
160162
it('increases the spender allowance adding the requested amount', async function () {
161163
await this.token.increaseAllowance(spender, amount, { from: initialHolder });
162164

163-
(await this.token.allowance(initialHolder, spender)).should.be.bignumber.equal(amount.addn(1));
165+
expect(await this.token.allowance(initialHolder, spender)).to.be.bignumber.equal(amount.addn(1));
164166
});
165167
});
166168
});
@@ -193,11 +195,11 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) {
193195

194196
it('increments totalSupply', async function () {
195197
const expectedSupply = initialSupply.add(amount);
196-
(await this.token.totalSupply()).should.be.bignumber.equal(expectedSupply);
198+
expect(await this.token.totalSupply()).to.be.bignumber.equal(expectedSupply);
197199
});
198200

199201
it('increments recipient balance', async function () {
200-
(await this.token.balanceOf(recipient)).should.be.bignumber.equal(amount);
202+
expect(await this.token.balanceOf(recipient)).to.be.bignumber.equal(amount);
201203
});
202204

203205
it('emits Transfer event', async function () {
@@ -206,7 +208,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) {
206208
to: recipient,
207209
});
208210

209-
event.args.value.should.be.bignumber.equal(amount);
211+
expect(event.args.value).to.be.bignumber.equal(amount);
210212
});
211213
});
212214
});
@@ -233,12 +235,12 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) {
233235

234236
it('decrements totalSupply', async function () {
235237
const expectedSupply = initialSupply.sub(amount);
236-
(await this.token.totalSupply()).should.be.bignumber.equal(expectedSupply);
238+
expect(await this.token.totalSupply()).to.be.bignumber.equal(expectedSupply);
237239
});
238240

239241
it('decrements initialHolder balance', async function () {
240242
const expectedBalance = initialSupply.sub(amount);
241-
(await this.token.balanceOf(initialHolder)).should.be.bignumber.equal(expectedBalance);
243+
expect(await this.token.balanceOf(initialHolder)).to.be.bignumber.equal(expectedBalance);
242244
});
243245

244246
it('emits Transfer event', async function () {
@@ -247,7 +249,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) {
247249
to: ZERO_ADDRESS,
248250
});
249251

250-
event.args.value.should.be.bignumber.equal(amount);
252+
expect(event.args.value).to.be.bignumber.equal(amount);
251253
});
252254
});
253255
};
@@ -294,17 +296,17 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) {
294296

295297
it('decrements totalSupply', async function () {
296298
const expectedSupply = initialSupply.sub(amount);
297-
(await this.token.totalSupply()).should.be.bignumber.equal(expectedSupply);
299+
expect(await this.token.totalSupply()).to.be.bignumber.equal(expectedSupply);
298300
});
299301

300302
it('decrements initialHolder balance', async function () {
301303
const expectedBalance = initialSupply.sub(amount);
302-
(await this.token.balanceOf(initialHolder)).should.be.bignumber.equal(expectedBalance);
304+
exxpect(await this.token.balanceOf(initialHolder)).to.be.bignumber.equal(expectedBalance);
303305
});
304306

305307
it('decrements spender allowance', async function () {
306308
const expectedAllowance = allowance.sub(amount);
307-
(await this.token.allowance(initialHolder, spender)).should.be.bignumber.equal(expectedAllowance);
309+
exxpect(await this.token.allowance(initialHolder, spender)).to.be.bignumber.equal(expectedAllowance);
308310
});
309311

310312
it('emits a Transfer event', async function () {
@@ -313,7 +315,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) {
313315
to: ZERO_ADDRESS,
314316
});
315317

316-
event.args.value.should.be.bignumber.equal(amount);
318+
expect(event.args.value).to.be.bignumber.equal(amount);
317319
});
318320

319321
it('emits an Approval event', async function () {

test/token/ERC20/ERC20Detailed.test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const { BN } = require('openzeppelin-test-helpers');
22

3+
const { expect } = require('chai');
4+
35
const ERC20DetailedMock = artifacts.require('ERC20DetailedMock');
46

57
contract('ERC20Detailed', function () {
@@ -12,14 +14,14 @@ contract('ERC20Detailed', function () {
1214
});
1315

1416
it('has a name', async function () {
15-
(await this.detailedERC20.name()).should.be.equal(_name);
17+
expect(await this.detailedERC20.name()).to.equal(_name);
1618
});
1719

1820
it('has a symbol', async function () {
19-
(await this.detailedERC20.symbol()).should.be.equal(_symbol);
21+
expect(await this.detailedERC20.symbol()).to.equal(_symbol);
2022
});
2123

2224
it('has an amount of decimals', async function () {
23-
(await this.detailedERC20.decimals()).should.be.bignumber.equal(_decimals);
25+
expect(await this.detailedERC20.decimals()).to.be.bignumber.equal(_decimals);
2426
});
2527
});

0 commit comments

Comments
 (0)