diff options
author | Sebastian <sebasjm@gmail.com> | 2022-06-06 00:09:25 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-06-06 00:09:25 -0300 |
commit | fb6aff76d2152d95caa2ba6cb0d91cb01e0687fe (patch) | |
tree | 2dc9b0a4935f60ba7229fd81332ec4a41ad4698c /packages/taler-wallet-webextension/src/cta/Tip.test.ts | |
parent | 912813fd09ee2f757e4d6d509a911159b46153a7 (diff) | |
download | wallet-core-fb6aff76d2152d95caa2ba6cb0d91cb01e0687fe.tar.xz |
prettier
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta/Tip.test.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/cta/Tip.test.ts | 161 |
1 files changed, 81 insertions, 80 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/Tip.test.ts b/packages/taler-wallet-webextension/src/cta/Tip.test.ts index 0eda9b5be..192173463 100644 --- a/packages/taler-wallet-webextension/src/cta/Tip.test.ts +++ b/packages/taler-wallet-webextension/src/cta/Tip.test.ts @@ -26,64 +26,67 @@ import { useComponentState } from "./Tip.jsx"; describe("Tip CTA states", () => { it("should tell the user that the URI is missing", async () => { - const { getLastResultOrThrow, waitNextUpdate, assertNoPendingUpdate } = mountHook(() => - useComponentState(undefined, { - prepareTip: async () => ({}), - acceptTip: async () => ({}) - } as any), - ); + const { getLastResultOrThrow, waitNextUpdate, assertNoPendingUpdate } = + mountHook(() => + useComponentState(undefined, { + prepareTip: async () => ({}), + acceptTip: async () => ({}), + } as any), + ); { - const { status, hook } = getLastResultOrThrow() - expect(status).equals('loading') + const { status, hook } = getLastResultOrThrow(); + expect(status).equals("loading"); expect(hook).undefined; } - await waitNextUpdate() + await waitNextUpdate(); { - const { status, hook } = getLastResultOrThrow() + const { status, hook } = getLastResultOrThrow(); - expect(status).equals('loading') + expect(status).equals("loading"); if (!hook) expect.fail(); if (!hook.hasError) expect.fail(); if (hook.operational) expect.fail(); expect(hook.message).eq("ERROR_NO-URI-FOR-TIP"); } - await assertNoPendingUpdate() + await assertNoPendingUpdate(); }); it("should be ready for accepting the tip", async () => { let tipAccepted = false; - const { getLastResultOrThrow, waitNextUpdate, assertNoPendingUpdate } = mountHook(() => - useComponentState("taler://tip/asd", { - 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), - ); + const { getLastResultOrThrow, waitNextUpdate, assertNoPendingUpdate } = + mountHook(() => + useComponentState("taler://tip/asd", { + 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), + ); { - const { status, hook } = getLastResultOrThrow() - expect(status).equals('loading') + const { status, hook } = getLastResultOrThrow(); + expect(status).equals("loading"); expect(hook).undefined; } - await waitNextUpdate() + await waitNextUpdate(); { - const state = getLastResultOrThrow() + const state = getLastResultOrThrow(); - if (state.status !== "ready") expect.fail() + if (state.status !== "ready") expect.fail(); if (state.hook) expect.fail(); expect(state.amount).deep.eq(Amounts.parseOrThrow("EUR:1")); expect(state.merchantBaseUrl).eq("merchant url"); @@ -93,45 +96,46 @@ describe("Tip CTA states", () => { state.accept.onClick(); } - await waitNextUpdate() + await waitNextUpdate(); { - const state = getLastResultOrThrow() + const state = getLastResultOrThrow(); - if (state.status !== "accepted") expect.fail() + if (state.status !== "accepted") expect.fail(); if (state.hook) expect.fail(); expect(state.amount).deep.eq(Amounts.parseOrThrow("EUR:1")); expect(state.merchantBaseUrl).eq("merchant url"); expect(state.exchangeBaseUrl).eq("exchange url"); - } - await assertNoPendingUpdate() + await assertNoPendingUpdate(); }); it("should be ignored after clicking the ignore button", async () => { - const { getLastResultOrThrow, waitNextUpdate, assertNoPendingUpdate } = mountHook(() => - useComponentState("taler://tip/asd", { - prepareTip: async () => ({ - exchangeBaseUrl: "exchange url", - merchantBaseUrl: "merchant url", - tipAmountEffective: "EUR:1", - walletTipId: "tip_id", - } as PrepareTipResult as any), - acceptTip: async () => ({}) - } as any), - ); + const { getLastResultOrThrow, waitNextUpdate, assertNoPendingUpdate } = + mountHook(() => + useComponentState("taler://tip/asd", { + prepareTip: async () => + ({ + exchangeBaseUrl: "exchange url", + merchantBaseUrl: "merchant url", + tipAmountEffective: "EUR:1", + walletTipId: "tip_id", + } as PrepareTipResult as any), + acceptTip: async () => ({}), + } as any), + ); { - const { status, hook } = getLastResultOrThrow() - expect(status).equals('loading') + const { status, hook } = getLastResultOrThrow(); + expect(status).equals("loading"); expect(hook).undefined; } - await waitNextUpdate() + await waitNextUpdate(); { - const state = getLastResultOrThrow() + const state = getLastResultOrThrow(); - if (state.status !== "ready") expect.fail() + if (state.status !== "ready") expect.fail(); if (state.hook) expect.fail(); expect(state.amount).deep.eq(Amounts.parseOrThrow("EUR:1")); expect(state.merchantBaseUrl).eq("merchant url"); @@ -141,52 +145,49 @@ describe("Tip CTA states", () => { state.ignore.onClick(); } - await waitNextUpdate() + await waitNextUpdate(); { - const state = getLastResultOrThrow() + const state = getLastResultOrThrow(); - if (state.status !== "ignored") expect.fail() + if (state.status !== "ignored") expect.fail(); if (state.hook) expect.fail(); - } - await assertNoPendingUpdate() + await assertNoPendingUpdate(); }); it("should render accepted if the tip has been used previously", async () => { - - const { getLastResultOrThrow, waitNextUpdate, assertNoPendingUpdate } = mountHook(() => - useComponentState("taler://tip/asd", { - prepareTip: async () => ({ - accepted: true, - exchangeBaseUrl: "exchange url", - merchantBaseUrl: "merchant url", - tipAmountEffective: "EUR:1", - walletTipId: "tip_id", - } as PrepareTipResult as any), - acceptTip: async () => ({}) - } as any), - ); + const { getLastResultOrThrow, waitNextUpdate, assertNoPendingUpdate } = + mountHook(() => + useComponentState("taler://tip/asd", { + prepareTip: async () => + ({ + accepted: true, + exchangeBaseUrl: "exchange url", + merchantBaseUrl: "merchant url", + tipAmountEffective: "EUR:1", + walletTipId: "tip_id", + } as PrepareTipResult as any), + acceptTip: async () => ({}), + } as any), + ); { - const { status, hook } = getLastResultOrThrow() - expect(status).equals('loading') + const { status, hook } = getLastResultOrThrow(); + expect(status).equals("loading"); expect(hook).undefined; } - await waitNextUpdate() + await waitNextUpdate(); { - const state = getLastResultOrThrow() + const state = getLastResultOrThrow(); - if (state.status !== "accepted") expect.fail() + if (state.status !== "accepted") expect.fail(); if (state.hook) expect.fail(); expect(state.amount).deep.eq(Amounts.parseOrThrow("EUR:1")); expect(state.merchantBaseUrl).eq("merchant url"); expect(state.exchangeBaseUrl).eq("exchange url"); - } - await assertNoPendingUpdate() + await assertNoPendingUpdate(); }); - - -});
\ No newline at end of file +}); |