Skip to content

Commit

Permalink
Write test related to add pet
Browse files Browse the repository at this point in the history
  • Loading branch information
riadelimemmedov committed Jan 27, 2024
1 parent b643333 commit 16206ef
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions blockchain/test/PetAdoption.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ describe("PetAdoption", function () {

async function deployContractFixture() {
// eslint-disable-next-line no-undef
const PETS_COUNT = 5
const [deployer,account2] = await hre.ethers.getSigners()
const contract = await (await ethers.getContractFactory("PetAdoption")).deploy()
const randomNumber = Math.random()
const contract = await (await ethers.getContractFactory("PetAdoption")).deploy(PETS_COUNT)
return {
deployer,
account2,
contract,
randomNumber
petsAddedCount:PETS_COUNT
}
}

Expand All @@ -43,5 +43,10 @@ describe("PetAdoption", function () {
const {account2,contract} = await loadFixture(deployContractFixture)
await expect(contract.connect(account2).addPet()).to.be.revertedWith("Only a contract owner can be add a new pet!")//Error text must be match to require message text on smart contract
})
it("should increase pet index", async function () {
const {petsAddedCount,contract} = await loadFixture(deployContractFixture)
await contract.addPet()
expect(await contract.petIndex()).to.equal(petsAddedCount+1)//I am wait 6
})
})
})

0 comments on commit 16206ef

Please sign in to comment.