const{expect}=require("chai");const{ethers,waffle}=require("hardhat");constprovider=waffle.provider;describe("StakedNFT",function(){let_id=1234567890;letvalue='1.5';letToken;letInterface;letowner;letaddr1;letaddr2;beforeEach(asyncfunction(){Token=awaitethers.getContractFactory("ERC721Staked");[owner,addr1,...addr2]=awaitethers.getSigners();Interface=awaitToken.deploy();});describe("Staked NFT",function(){it("Should set the right owner",asyncfunction(){letmint=awaitInterface.mint(addr1.address,_id,'http://foobar')expect(awaitInterface.ownerOf(_id)).to.equal(addr1.address);});it("Should not have staked balance without value",asyncfunction(){letmint=awaitInterface.mint(addr1.address,_id,'http://foobar')expect(awaitInterface.stakedAmount(_id)).to.equal(ethers.utils.parseEther('0'));});it("Should set and return the staked amount",asyncfunction(){letmint=awaitInterface.mint(addr1.address,_id,'http://foobar',{value:ethers.utils.parseEther(value)})expect(awaitInterface.stakedAmount(_id)).to.equal(ethers.utils.parseEther(value));});it("Should decrease owner eth balance on mint (deposit)",asyncfunction(){letbalance1=awaitprovider.getBalance(owner.address);letmint=awaitInterface.mint(addr1.address,_id,'http://foobar',{value:ethers.utils.parseEther(value)})letbalance2=awaitprovider.getBalance(owner.address);letdiff=parseFloat(ethers.utils.formatEther(balance1.sub(balance2))).toFixed(1);expect(diff===value);});it("Should add to payee's eth balance on burn (withdraw)",asyncfunction(){letbalance1=awaitprovider.getBalance(addr1.address);letmint=awaitInterface.mint(addr1.address,_id,'http://foobar',{value:ethers.utils.parseEther(value)})awaitInterface.burn(_id);letbalance2=awaitprovider.getBalance(addr1.address);letdiff=parseFloat(ethers.utils.formatEther(balance2.sub(balance1))).toFixed(1);expect(diff===value);});it("Should update balance after transfer",asyncfunction(){letmint=awaitInterface.mint(addr1.address,_id,'http://foobar',{value:ethers.utils.parseEther(value)})awaitInterface.burn(_id);expect(awaitInterface.stakedAmount(_id)).to.equal(ethers.utils.parseEther('0'));});});});