From c640c0738b501b5b4fc5442e26bb6d041526f8fb Mon Sep 17 00:00:00 2001 From: mehditorabiv Date: Mon, 25 Nov 2024 14:16:25 +0300 Subject: [PATCH] lint --- ignition/modules/Engagement.ts | 6 ++-- test/Engagement.ts | 57 ++++++++++++++++++---------------- 2 files changed, 34 insertions(+), 29 deletions(-) diff --git a/ignition/modules/Engagement.ts b/ignition/modules/Engagement.ts index e0eae83..431a761 100644 --- a/ignition/modules/Engagement.ts +++ b/ignition/modules/Engagement.ts @@ -1,11 +1,11 @@ import { buildModule } from "@nomicfoundation/hardhat-ignition/modules"; const EngagementModule = buildModule("EngagementModule", (m) => { - const uri = m.getParameter("uri"); + const uri = m.getParameter("uri"); const engagement = m.contract("Engagement", [uri], {}); - + return { engagement }; }); -export default EngagementModule; \ No newline at end of file +export default EngagementModule; diff --git a/test/Engagement.ts b/test/Engagement.ts index 0080c88..6666ce6 100644 --- a/test/Engagement.ts +++ b/test/Engagement.ts @@ -25,26 +25,27 @@ describe("Engagement", () => { describe("Success", () => { it("Shuld have counter equal 0", async () => { const { contract } = await loadFixture(deployFixture); - + expect(await contract.read.counter()).to.be.equal(parseUnits("0", 0)); }); - + it("Should have deployer as an Admin", async () => { const { contract, deployer } = await loadFixture(deployFixture); - + const adminRole = await contract.read.DEFAULT_ADMIN_ROLE(); - - expect(await contract.read.hasRole([adminRole, deployer.account.address])) - .to.be.true; + + expect( + await contract.read.hasRole([adminRole, deployer.account.address]), + ).to.be.true; }); - }) + }); describe("Revert", () => { it("Should revert deployment if URI is empty", async () => { await expect( - hre.viem.deployContract("Engagement", [""]) - ).to.be.rejectedWith("URIEmpty(\"URI cannot be empty\")"); + hre.viem.deployContract("Engagement", [""]), + ).to.be.rejectedWith('URIEmpty("URI cannot be empty")'); }); - }) + }); }); describe("Issue", () => { @@ -107,48 +108,52 @@ describe("Engagement", () => { it("Should allow admin to update base URI", async () => { const { contract, deployer } = await loadFixture(deployFixture); const newURI = "https://new-api.example.com"; - + await contract.write.issue({ account: deployer.account.address }); - - await contract.write.updateBaseURI([newURI], { account: deployer.account.address }); - - expect(await contract.read.uri([parseUnits("0", 0)])).to.be.equal(`${newURI}/0.json`); + + await contract.write.updateBaseURI([newURI], { + account: deployer.account.address, + }); + + expect(await contract.read.uri([parseUnits("0", 0)])).to.be.equal( + `${newURI}/0.json`, + ); }); - + it("Should emit BaseURIUpdated event on URI change", async () => { const { contract, deployer } = await loadFixture(deployFixture); const newURI = "https://new-api.example.com"; - + const updateTx = await contract.write.updateBaseURI([newURI], { account: deployer.account.address, }); - + const baseURIEvents = await contract.getEvents.BaseURIUpdated(); - + expect(baseURIEvents.length).to.be.equal(1); - + const event = baseURIEvents[0]; expect(event.eventName).to.be.equal("BaseURIUpdated"); expect(event.args.oldURI).to.be.equal(DEFAULT_URI); expect(event.args.newURI).to.be.equal(newURI); }); - }) + }); describe("Revert", () => { it("Should revert if non-admin tries to update URI", async () => { const { contract, otherAccount } = await loadFixture(deployFixture); - + await expect( contract.write.updateBaseURI(["https://new-api.example.com"], { account: otherAccount.account.address, - }) + }), ).to.be.rejectedWith( `AccessControlUnauthorizedAccount("${getAddress( - otherAccount.account.address - )}", "0x0000000000000000000000000000000000000000000000000000000000000000")` + otherAccount.account.address, + )}", "0x0000000000000000000000000000000000000000000000000000000000000000")`, ); }); - }) + }); }); describe("Uri", () => {