Skip to content

Commit

Permalink
Added with no minted tokens tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorized committed Apr 3, 2022
1 parent 6369673 commit 5e77de2
Showing 1 changed file with 57 additions and 18 deletions.
75 changes: 57 additions & 18 deletions test/extensions/ERC721AQueries.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 5e77de2

Please sign in to comment.