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 hyperledger#3473

Signed-off-by: ashnashahgrover <[email protected]>
  • Loading branch information
ashnashahgrover authored and outSH committed Aug 22, 2024
1 parent ec9683d commit bf35762
Showing 1 changed file with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,33 +177,31 @@ 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();

try {
await connector.addAriesAgent({
log.info(
"Adding aries agent with inbound url 'foo' throws error as expected",
);

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 bf35762

Please sign in to comment.