From 368d228b0eefe83393db0f116078ffde6325c831 Mon Sep 17 00:00:00 2001 From: Jose Felix Date: Thu, 6 Jun 2024 10:38:40 -0500 Subject: [PATCH] test: fix tests --- .../one-click-trading-settings.spec.ts | 24 ------------------- ...e-create-one-click-trading-session.spec.ts | 12 ++++------ 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/packages/web/components/one-click-trading/__tests__/one-click-trading-settings.spec.ts b/packages/web/components/one-click-trading/__tests__/one-click-trading-settings.spec.ts index 796b92c8389..db9851178cb 100644 --- a/packages/web/components/one-click-trading/__tests__/one-click-trading-settings.spec.ts +++ b/packages/web/components/one-click-trading/__tests__/one-click-trading-settings.spec.ts @@ -23,7 +23,6 @@ describe("compare1CTTransactionParams", () => { isOneClickEnabled: true, spendLimit: mockPricePretty(5000), networkFeeLimit: mockCoinPretty(13485), - resetPeriod: "day", sessionPeriod: { end: "1hour" }, }; @@ -38,7 +37,6 @@ describe("compare1CTTransactionParams", () => { isOneClickEnabled: true, spendLimit: mockPricePretty(5000), networkFeeLimit: mockCoinPretty(13485), - resetPeriod: "day", sessionPeriod: { end: "1hour" }, }; @@ -56,7 +54,6 @@ describe("compare1CTTransactionParams", () => { isOneClickEnabled: true, spendLimit: mockPricePretty(5000), networkFeeLimit: mockCoinPretty(13485), - resetPeriod: "day", sessionPeriod: { end: "1hour" }, }; @@ -69,30 +66,11 @@ describe("compare1CTTransactionParams", () => { expect(changes).toContain("networkFeeLimit"); }); - it("should detect changes in resetPeriod", () => { - const prevParams: OneClickTradingTransactionParams = { - isOneClickEnabled: true, - spendLimit: mockPricePretty(5000), - networkFeeLimit: mockCoinPretty(13485), - resetPeriod: "day", - sessionPeriod: { end: "1hour" }, - }; - - const nextParams: OneClickTradingTransactionParams = { - ...prevParams, - resetPeriod: "week", - }; - - const changes = compare1CTTransactionParams({ prevParams, nextParams }); - expect(changes).toContain("resetPeriod"); - }); - it("should detect multiple changes including sessionPeriod", () => { const prevParams: OneClickTradingTransactionParams = { isOneClickEnabled: true, spendLimit: mockPricePretty(5000), networkFeeLimit: mockCoinPretty(13485), - resetPeriod: "day", sessionPeriod: { end: "1hour" }, }; @@ -100,14 +78,12 @@ describe("compare1CTTransactionParams", () => { ...prevParams, spendLimit: mockPricePretty(7000), networkFeeLimit: mockCoinPretty(16000), - resetPeriod: "month", sessionPeriod: { end: "3hours" }, }; const changes = compare1CTTransactionParams({ prevParams, nextParams }); expect(changes).toContain("spendLimit"); expect(changes).toContain("networkFeeLimit"); - expect(changes).toContain("resetPeriod"); expect(changes).toContain("sessionPeriod"); }); }); diff --git a/packages/web/hooks/mutations/one-click-trading/__tests__/use-create-one-click-trading-session.spec.ts b/packages/web/hooks/mutations/one-click-trading/__tests__/use-create-one-click-trading-session.spec.ts index 82ea6274349..e9bf3333b64 100644 --- a/packages/web/hooks/mutations/one-click-trading/__tests__/use-create-one-click-trading-session.spec.ts +++ b/packages/web/hooks/mutations/one-click-trading/__tests__/use-create-one-click-trading-session.spec.ts @@ -18,7 +18,6 @@ jest.mock("~/config", () => ({ describe("isAuthenticatorOneClickTradingSession", () => { const key = new PrivKeySecp256k1(Buffer.from("key")); const allowedAmount = "1000"; - const resetPeriod = "day"; const allowedMessages: AvailableOneClickTradingMessages[] = [ "/osmosis.poolmanager.v1beta1.MsgSwapExactAmountIn", "/osmosis.poolmanager.v1beta1.MsgSplitRouteSwapExactAmountIn", @@ -29,7 +28,6 @@ describe("isAuthenticatorOneClickTradingSession", () => { const rawAuthenticator = getOneClickTradingSessionAuthenticator({ key, allowedAmount, - resetPeriod, allowedMessages, sessionPeriod, }); @@ -46,7 +44,7 @@ describe("isAuthenticatorOneClickTradingSession", () => { it("should return false for an invalid 1-Click Trading Session authenticator", () => { const authenticator = { type: "AllOf", - subAuthenticators: [{ type: "InvalidType" }], + subAuthenticators: [{ type: "Invalidtype" }], }; expect( isAuthenticatorOneClickTradingSession({ @@ -60,7 +58,6 @@ describe("getOneClickTradingSessionAuthenticator", () => { it("should generate a correct 1-Click Trading Session authenticator", () => { const key = PrivKeySecp256k1.generateRandomKey(); const allowedAmount = "1000"; - const resetPeriod = "day"; const allowedMessages: AvailableOneClickTradingMessages[] = [ "/osmosis.poolmanager.v1beta1.MsgSwapExactAmountIn", "/osmosis.poolmanager.v1beta1.MsgSplitRouteSwapExactAmountIn", @@ -70,7 +67,6 @@ describe("getOneClickTradingSessionAuthenticator", () => { const result = getOneClickTradingSessionAuthenticator({ key, allowedAmount, - resetPeriod, allowedMessages, sessionPeriod, }); @@ -78,9 +74,9 @@ describe("getOneClickTradingSessionAuthenticator", () => { expect(result.type).toEqual("AllOf"); const data = JSON.parse(Buffer.from(result.data).toString()); expect(data).toHaveLength(3); - expect(data[0].Type).toEqual("SignatureVerification"); - expect(data[1].Type).toEqual("CosmwasmAuthenticatorV1"); - expect(data[2].Type).toEqual("AnyOf"); + expect(data[0].type).toEqual("SignatureVerification"); + expect(data[1].type).toEqual("CosmwasmAuthenticatorV1"); + expect(data[2].type).toEqual("AnyOf"); }); });