diff options
author | Sebastian <sebasjm@gmail.com> | 2022-09-16 14:29:35 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-09-16 14:29:35 -0300 |
commit | 6ddb2de84245ae3914c92b2b2eb7399e7f04500e (patch) | |
tree | 425cc377daf053e5283bee6986f6f437f25d7584 /packages/taler-wallet-webextension/src/cta/Tip/test.ts | |
parent | 860f10e6f004668d3109b5a1d96ddb2b26ddc2f5 (diff) | |
download | wallet-core-6ddb2de84245ae3914c92b2b2eb7399e7f04500e.tar.xz |
pretty
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta/Tip/test.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/cta/Tip/test.ts | 110 |
1 files changed, 70 insertions, 40 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/Tip/test.ts b/packages/taler-wallet-webextension/src/cta/Tip/test.ts index ccb36572e..4895fcc7f 100644 --- a/packages/taler-wallet-webextension/src/cta/Tip/test.ts +++ b/packages/taler-wallet-webextension/src/cta/Tip/test.ts @@ -19,9 +19,7 @@ * @author Sebastian Javier Marchano (sebasjm) */ -import { - Amounts, PrepareTipResult -} from "@gnu-taler/taler-util"; +import { Amounts, PrepareTipResult } from "@gnu-taler/taler-util"; import { expect } from "chai"; import { mountHook } from "../../test-utils.js"; import { useComponentState } from "./state.js"; @@ -30,10 +28,18 @@ describe("Tip CTA states", () => { it("should tell the user that the URI is missing", async () => { const { getLastResultOrThrow, waitNextUpdate, assertNoPendingUpdate } = mountHook(() => - useComponentState({ talerTipUri: undefined, onCancel: async () => { null } }, { - prepareTip: async () => ({}), - acceptTip: async () => ({}), - } as any), + useComponentState( + { + talerTipUri: undefined, + onCancel: async () => { + null; + }, + }, + { + prepareTip: async () => ({}), + acceptTip: async () => ({}), + } as any, + ), ); { @@ -62,19 +68,27 @@ describe("Tip CTA states", () => { const { getLastResultOrThrow, waitNextUpdate, assertNoPendingUpdate } = mountHook(() => - useComponentState({ talerTipUri: "taler://tip/asd", onCancel: async () => { null } }, { - prepareTip: async () => - ({ - accepted: tipAccepted, - exchangeBaseUrl: "exchange url", - merchantBaseUrl: "merchant url", - tipAmountEffective: "EUR:1", - walletTipId: "tip_id", - } as PrepareTipResult as any), - acceptTip: async () => { - tipAccepted = true; + useComponentState( + { + talerTipUri: "taler://tip/asd", + onCancel: async () => { + null; + }, }, - } as any), + { + prepareTip: async () => + ({ + accepted: tipAccepted, + exchangeBaseUrl: "exchange url", + merchantBaseUrl: "merchant url", + tipAmountEffective: "EUR:1", + walletTipId: "tip_id", + } as PrepareTipResult as any), + acceptTip: async () => { + tipAccepted = true; + }, + } as any, + ), ); { @@ -114,16 +128,24 @@ describe("Tip CTA states", () => { it("should be ignored after clicking the ignore button", async () => { const { getLastResultOrThrow, waitNextUpdate, assertNoPendingUpdate } = mountHook(() => - useComponentState({ talerTipUri: "taler://tip/asd", onCancel: async () => { null } }, { - prepareTip: async () => - ({ - exchangeBaseUrl: "exchange url", - merchantBaseUrl: "merchant url", - tipAmountEffective: "EUR:1", - walletTipId: "tip_id", - } as PrepareTipResult as any), - acceptTip: async () => ({}), - } as any), + useComponentState( + { + talerTipUri: "taler://tip/asd", + onCancel: async () => { + null; + }, + }, + { + prepareTip: async () => + ({ + exchangeBaseUrl: "exchange url", + merchantBaseUrl: "merchant url", + tipAmountEffective: "EUR:1", + walletTipId: "tip_id", + } as PrepareTipResult as any), + acceptTip: async () => ({}), + } as any, + ), ); { @@ -160,17 +182,25 @@ describe("Tip CTA states", () => { it("should render accepted if the tip has been used previously", async () => { const { getLastResultOrThrow, waitNextUpdate, assertNoPendingUpdate } = mountHook(() => - useComponentState({ talerTipUri: "taler://tip/asd", onCancel: async () => { null } }, { - prepareTip: async () => - ({ - accepted: true, - exchangeBaseUrl: "exchange url", - merchantBaseUrl: "merchant url", - tipAmountEffective: "EUR:1", - walletTipId: "tip_id", - } as PrepareTipResult as any), - acceptTip: async () => ({}), - } as any), + useComponentState( + { + talerTipUri: "taler://tip/asd", + onCancel: async () => { + null; + }, + }, + { + prepareTip: async () => + ({ + accepted: true, + exchangeBaseUrl: "exchange url", + merchantBaseUrl: "merchant url", + tipAmountEffective: "EUR:1", + walletTipId: "tip_id", + } as PrepareTipResult as any), + acceptTip: async () => ({}), + } as any, + ), ); { |