Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions test/helpers/sendTransaction.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const _ = require('lodash');
const ethjsABI = require('ethjs-abi');

function findMethod (abi, name, args) {
for (let i = 0; i < abi.length; i++) {
const methodArgs = _.map(abi[i].inputs, 'type').join(',');
const methodArgs = abi[i].inputs.map(input => input.type).join(',');
if ((abi[i].name === name) && (methodArgs === args)) {
return abi[i];
}
Expand Down
5 changes: 3 additions & 2 deletions test/token/ERC721/ERC721.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const { shouldSupportInterfaces } = require('../../introspection/SupportsInterfa
const { assertRevert } = require('../../helpers/assertRevert');
const { decodeLogs } = require('../../helpers/decodeLogs');
const { sendTransaction } = require('../../helpers/sendTransaction');
const _ = require('lodash');

const ERC721Receiver = artifacts.require('ERC721ReceiverMock.sol');
const BigNumber = web3.BigNumber;
Expand Down Expand Up @@ -175,7 +174,9 @@ function shouldBehaveLikeERC721 (

it('keeps same tokens by index', async function () {
if (!this.token.tokenOfOwnerByIndex) return;
const tokensListed = await Promise.all(_.range(2).map(i => this.token.tokenOfOwnerByIndex(owner, i)));
const tokensListed = await Promise.all(
[0, 1].map(i => this.token.tokenOfOwnerByIndex(owner, i))
);
tokensListed.map(t => t.toNumber()).should.have.members([firstTokenId, secondTokenId]);
});
});
Expand Down
16 changes: 10 additions & 6 deletions test/token/ERC721/ERC721Full.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const { assertRevert } = require('../../helpers/assertRevert');
const { shouldBehaveLikeERC721 } = require('./ERC721.behavior');
const { shouldBehaveLikeMintAndBurnERC721 } = require('./ERC721MintBurn.behavior');
const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior');
const _ = require('lodash');

const BigNumber = web3.BigNumber;
const ERC721FullMock = artifacts.require('ERC721FullMock.sol');
Expand Down Expand Up @@ -173,7 +172,9 @@ contract('ERC721Full', function ([

it('returns correct token IDs for target', async function () {
(await this.token.balanceOf(another)).toNumber().should.be.equal(2);
const tokensListed = await Promise.all(_.range(2).map(i => this.token.tokenOfOwnerByIndex(another, i)));
const tokensListed = await Promise.all(
[0, 1].map(i => this.token.tokenOfOwnerByIndex(another, i))
);
tokensListed.map(t => t.toNumber()).should.have.members([firstTokenId, secondTokenId]);
});

Expand All @@ -186,7 +187,9 @@ contract('ERC721Full', function ([

describe('tokenByIndex', function () {
it('should return all tokens', async function () {
const tokensListed = await Promise.all(_.range(2).map(i => this.token.tokenByIndex(i)));
const tokensListed = await Promise.all(
[0, 1].map(i => this.token.tokenByIndex(i))
);
tokensListed.map(t => t.toNumber()).should.have.members([firstTokenId, secondTokenId]);
});

Expand All @@ -205,9 +208,10 @@ contract('ERC721Full', function ([

(await this.token.totalSupply()).toNumber().should.be.equal(3);

const tokensListed = await Promise.all(_.range(3).map(i => this.token.tokenByIndex(i)));
const expectedTokens = _.filter(
[firstTokenId, secondTokenId, newTokenId, anotherNewTokenId],
const tokensListed = await Promise.all(
[0, 1, 2].map(i => this.token.tokenByIndex(i))
);
const expectedTokens = [firstTokenId, secondTokenId, newTokenId, anotherNewTokenId].filter(
x => (x !== tokenId)
);
tokensListed.map(t => t.toNumber()).should.have.members(expectedTokens);
Expand Down