Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorized committed Feb 2, 2024
1 parent c6b0f02 commit 8656cf0
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions test/extensions/ERC721ASpot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,8 @@ describe('ERC721ASpot', function () {
});

context('with transfers', function () {
beforeEach(async function () {
await this.erc721aSpot.safeMint(this.addr1.address, 5);
});

it('reverts if token is not minted', async function () {
await this.erc721aSpot.safeMint(this.addr1.address, 10);
await expect(this.erc721aSpot
.connect(this.addr1)
.transferFrom(this.addr1.address, this.owner.address, 21)).to.be.revertedWith(
Expand All @@ -180,6 +177,32 @@ describe('ERC721ASpot', function () {
.connect(this.addr1)
.transferFrom(this.addr1.address, this.owner.address, 21);
});

it('edge case 1', async function () {
await this.erc721aSpot.safeMintSpot(this.addr1.address, 20);
await this.erc721aSpot.safeMint(this.addr1.address, 10);
await this.erc721aSpot.connect(this.addr1).transferFrom(this.addr1.address, this.owner.address, 20);
expect(await this.erc721aSpot.ownerOf(20)).to.eq(this.owner.address);
expect(await this.erc721aSpot.ownerOf(19)).to.eq(this.addr1.address);
expect(await this.erc721aSpot.ownerOf(18)).to.eq(this.addr1.address);
await this.erc721aSpot.connect(this.addr1).transferFrom(this.addr1.address, this.owner.address, 19);
expect(await this.erc721aSpot.ownerOf(20)).to.eq(this.owner.address);
expect(await this.erc721aSpot.ownerOf(19)).to.eq(this.owner.address);
expect(await this.erc721aSpot.ownerOf(18)).to.eq(this.addr1.address);
});

it('edge case 2', async function () {
await this.erc721aSpot.safeMintSpot(this.addr1.address, 20);
await this.erc721aSpot.safeMint(this.addr1.address, 10);
await this.erc721aSpot.connect(this.addr1).transferFrom(this.addr1.address, this.owner.address, 19);
expect(await this.erc721aSpot.ownerOf(20)).to.eq(this.addr1.address);
expect(await this.erc721aSpot.ownerOf(19)).to.eq(this.owner.address);
expect(await this.erc721aSpot.ownerOf(18)).to.eq(this.addr1.address);
await this.erc721aSpot.connect(this.addr1).transferFrom(this.addr1.address, this.owner.address, 20);
expect(await this.erc721aSpot.ownerOf(20)).to.eq(this.owner.address);
expect(await this.erc721aSpot.ownerOf(19)).to.eq(this.owner.address);
expect(await this.erc721aSpot.ownerOf(18)).to.eq(this.addr1.address);
});
});

context('with burns', function () {
Expand Down

0 comments on commit 8656cf0

Please sign in to comment.