Browse Source

Fix Part 1 : added tests for getApproved (#1820)

* added tests for getApproved

* added tests for getApproved

* added to changelog

* Corrected some linting issues

* Removed unneccrary tests as pointed out here: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/1820/commits/b49c2de086621745955be83a34a06de65e95c76c#r307927816

* Correct Changelog character

* Update ERC721.behavior.js
Jatin Kathuria 6 years ago
parent
commit
635a381460
1 changed files with 29 additions and 0 deletions
  1. 29 0
      test/token/ERC721/ERC721.behavior.js

+ 29 - 0
test/token/ERC721/ERC721.behavior.js

@@ -586,6 +586,35 @@ function shouldBehaveLikeERC721 (
       });
     });
 
+    describe('getApproved', async function () {
+      context('when token is not minted', async function () {
+        it('reverts', async function () {
+          await expectRevert(
+            this.token.getApproved(unknownTokenId, { from: minter }),
+            'ERC721: approved query for nonexistent token'
+          );
+        });
+      });
+
+      context('when token has been minted ', async function () {
+        it('should return the zero address', async function () {
+          expect(await this.token.getApproved(firstTokenId)).to.be.equal(
+            ZERO_ADDRESS
+          );
+        });
+
+        context('when account has been approved', async function () {
+          beforeEach(async function () {
+            await this.token.approve(approved, firstTokenId, { from: owner });
+          });
+
+          it('should return approved account', async function () {
+            expect(await this.token.getApproved(firstTokenId)).to.be.equal(approved);
+          });
+        });
+      });
+    });
+
     shouldSupportInterfaces([
       'ERC165',
       'ERC721',