Skip to content

Commit

Permalink
test(aries): refactor jest test negative test cases
Browse files Browse the repository at this point in the history
Primary Changes
----------------
1. Refactored all the negative test case exception assertions for
cactus-plugin-ledger-connector-aries. Removed try-catch blocks,
replaced with declarations through jest-extended's own API.

Fixes #3473

Signed-off-by: ashnashahgrover <ashnashahgrover777@gmail.com>
  • Loading branch information
ashnashahgrover committed Aug 12, 2024
1 parent b160c52 commit f500d5c
Showing 1 changed file with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,33 +177,29 @@ describe("Aries connector setup tests", () => {
test("Adding aries agent with invalid inbound url throws error", async () => {
const agentName = `shouldThrow-${uuidV4()}`;

try {
await connector.addAriesAgent({
await expect(
connector.addAriesAgent({
name: agentName,
walletKey: agentName,
indyNetworks: [fakeIndyNetworkConfig],
inboundUrl: "foo",
});
expect("should throw!").toBe(0);
} catch (error) {
log.info(
"Adding aries agent with inbound url 'foo' throws error as expected",
);
}
})
).rejects.toThrow();

log.info("Adding aries agent with inbound url 'foo' throws error as expected");

try {
await connector.addAriesAgent({
await expect(
connector.addAriesAgent({
name: agentName,
walletKey: agentName,
indyNetworks: [fakeIndyNetworkConfig],
inboundUrl: "http://127.0.0.1",
});
expect("should throw!").toBe(0);
} catch (error) {
log.info(
"Adding aries agent without inbound url port throws error as expected",
);
}
})
).rejects.toThrow();

log.info(
"Adding aries agent without inbound url port throws error as expected"
);

const allAgents = await connector.getAgents();
expect(allAgents.length).toBe(0);
Expand Down

0 comments on commit f500d5c

Please sign in to comment.