From bf357621fa0851b353bc112c1473332915289604 Mon Sep 17 00:00:00 2001 From: ashnashahgrover Date: Mon, 12 Aug 2024 17:59:52 +0000 Subject: [PATCH] test(aries): refactor jest test negative test cases 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 --- .../aries-setup-and-connections.test.ts | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/packages/cactus-plugin-ledger-connector-aries/src/test/typescript/integration/aries-setup-and-connections.test.ts b/packages/cactus-plugin-ledger-connector-aries/src/test/typescript/integration/aries-setup-and-connections.test.ts index 887ddf62d2..a1514901d6 100644 --- a/packages/cactus-plugin-ledger-connector-aries/src/test/typescript/integration/aries-setup-and-connections.test.ts +++ b/packages/cactus-plugin-ledger-connector-aries/src/test/typescript/integration/aries-setup-and-connections.test.ts @@ -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);