Skip to content

Commit

Permalink
feat: complete the getApplication function
Browse files Browse the repository at this point in the history
  • Loading branch information
Behzad-rabiei committed Jul 19, 2024
1 parent f6e1b08 commit fe83bcc
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion test/ApplicationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ describe("ApplicationManager", () => {
);
});
it("Should revert if the application does not exist", async () => {
await expect(contract.write.updateApplication(["1", app])).to.be.rejectedWith(
const nonExistentId = parseUnits("999", 0);
await expect(contract.write.updateApplication([nonExistentId, app])).to.be.rejectedWith(
"Application does not exist"
);
});
Expand Down Expand Up @@ -213,4 +214,40 @@ describe("ApplicationManager", () => {
expect(event.args.application).to.contain(app);
});
});


describe("getApplication", () => {
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
let contract: any;
let app: Application;
let applicationId: string;
let account= privateKeyToAccount(generatePrivateKey()).address

beforeEach(async () => {
const fixture = await loadFixture(deploy);
contract = fixture.contract;

app = {
name: "app",
account,
};

applicationId = await contract.read.getNextApplicationId();
await contract.write.createApplication([app]);
});

it("Should accept id as input", async () => {
expect(await contract.write.getApplication([applicationId])).to.be
.string;
});
it("Should return the application from the applications mapping with the provided applicationId", async () => {
expect(await contract.read.getApplication([applicationId])).to.contains(app);
});
it("Should revert if the application does not exist", async () => {
const nonExistentId = parseUnits("999", 0);
await expect( contract.read.getApplication([nonExistentId])).to.be.rejectedWith(
"Application does not exist"
);
});
});
});

0 comments on commit fe83bcc

Please sign in to comment.