diff --git a/test/extensions/ERC721AQueries.test.js b/test/extensions/ERC721AQueries.test.js index 6061baca0..63b14123a 100644 --- a/test/extensions/ERC721AQueries.test.js +++ b/test/extensions/ERC721AQueries.test.js @@ -18,6 +18,63 @@ const createTestSuite = ({ contract, constructorArgs, setOwnersExplicit = false offseted = (...arr) => arr.map((num) => BigNumber.from(this.startTokenId + num)); }); + const expectRawOwnershipBurned = function (rawOwnership, address) { + expect(rawOwnership.burned).to.eql(true); + expect(rawOwnership.addr).to.eql(address); + expect(rawOwnership.startTimestamp).to.not.eql(BigNumber.from(0)); + }; + + const expectRawOwnershipNotExists = function (rawOwnership) { + expect(rawOwnership.burned).to.eql(false); + expect(rawOwnership.addr).to.eql(ZERO_ADDRESS); + expect(rawOwnership.startTimestamp).to.eql(BigNumber.from(0)); + }; + + const expectRawOwnershipExists = function (rawOwnership, address) { + expect(rawOwnership.burned).to.eql(false); + expect(rawOwnership.addr).to.eql(address); + expect(rawOwnership.startTimestamp).to.not.eql(BigNumber.from(0)); + }; + + context('with no minted tokens', async function () { + beforeEach(async function () { + const [owner, addr1] = await ethers.getSigners(); + this.owner = owner; + this.addr1 = addr1; + }); + + describe('tokensOfOwner', async function () { + it('returns empty array', async function () { + expect(await this.erc721aQueries.tokensOfOwner(this.owner.address)).to.eql([]); + expect(await this.erc721aQueries.tokensOfOwner(this.addr1.address)).to.eql([]); + }); + }); + + describe('tokensOfOwnerIn', async function () { + it('returns empty array', async function () { + expect(await this.erc721aQueries.tokensOfOwnerIn(this.owner.address, 0, 9)).to.eql([]); + expect(await this.erc721aQueries.tokensOfOwnerIn(this.addr1.address, 0, 9)).to.eql([]); + }); + }); + + describe('rawOwnershipOf', async function () { + it('returns empty struct', async function () { + expectRawOwnershipNotExists(await this.erc721aQueries.rawOwnershipOf(0)); + expectRawOwnershipNotExists(await this.erc721aQueries.rawOwnershipOf(1)); + }); + }); + + describe('rawOwnershipsOf', async function () { + it('returns empty structs', async function () { + const tokenIds = [0, 1, 2, 3]; + const rawOwnerships = await this.erc721aQueries.rawOwnershipsOf(tokenIds); + for (let i = 0; i < rawOwnerships.length; ++i) { + expectRawOwnershipNotExists(rawOwnerships[i]); + } + }); + }); + }); + context('with minted tokens', async function () { beforeEach(async function () { const [owner, addr1, addr2, addr3, addr4] = await ethers.getSigners(); @@ -158,24 +215,6 @@ const createTestSuite = ({ contract, constructorArgs, setOwnersExplicit = false }); }); - const expectRawOwnershipBurned = function (rawOwnership, address) { - expect(rawOwnership.burned).to.eql(true); - expect(rawOwnership.addr).to.eql(address); - expect(rawOwnership.startTimestamp).to.not.eql(BigNumber.from(0)); - }; - - const expectRawOwnershipNotExists = function (rawOwnership) { - expect(rawOwnership.burned).to.eql(false); - expect(rawOwnership.addr).to.eql(ZERO_ADDRESS); - expect(rawOwnership.startTimestamp).to.eql(BigNumber.from(0)); - }; - - const expectRawOwnershipExists = function (rawOwnership, address) { - expect(rawOwnership.burned).to.eql(false); - expect(rawOwnership.addr).to.eql(address); - expect(rawOwnership.startTimestamp).to.not.eql(BigNumber.from(0)); - }; - describe('rawOwnershipOf', async function () { it('token exists', async function () { const tokenId = this.owner.expected.tokens[0];