aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/cta/Payment/test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta/Payment/test.ts')
-rw-r--r--packages/taler-wallet-webextension/src/cta/Payment/test.ts202
1 files changed, 105 insertions, 97 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/Payment/test.ts b/packages/taler-wallet-webextension/src/cta/Payment/test.ts
index 235b22c22..91d2d825d 100644
--- a/packages/taler-wallet-webextension/src/cta/Payment/test.ts
+++ b/packages/taler-wallet-webextension/src/cta/Payment/test.ts
@@ -75,6 +75,7 @@ describe("Payment CTA states", () => {
talerPayUri: undefined,
cancel: nullFunction,
goToWalletManualWithdraw: nullFunction,
+ onSuccess: async () => { null; },
},
{
onUpdateNotification: nullFunction,
@@ -110,18 +111,19 @@ describe("Payment CTA states", () => {
talerPayUri: "taller://pay",
cancel: nullFunction,
goToWalletManualWithdraw: nullFunction,
+ onSuccess: async () => { null; },
},
{
onUpdateNotification: nullFunction,
preparePay: async () =>
- ({
- amountRaw: "USD:10",
- status: PreparePayResultType.InsufficientBalance,
- } as Partial<PreparePayResult>),
+ ({
+ amountRaw: "USD:10",
+ status: PreparePayResultType.InsufficientBalance,
+ } as Partial<PreparePayResult>),
getBalance: async () =>
- ({
- balances: [],
- } as Partial<BalancesResponse>),
+ ({
+ balances: [],
+ } as Partial<BalancesResponse>),
} as Partial<typeof wxApi> as any,
),
);
@@ -152,22 +154,23 @@ describe("Payment CTA states", () => {
talerPayUri: "taller://pay",
cancel: nullFunction,
goToWalletManualWithdraw: nullFunction,
+ onSuccess: async () => { null; },
},
{
onUpdateNotification: nullFunction,
preparePay: async () =>
- ({
- amountRaw: "USD:10",
- status: PreparePayResultType.InsufficientBalance,
- } as Partial<PreparePayResult>),
+ ({
+ amountRaw: "USD:10",
+ status: PreparePayResultType.InsufficientBalance,
+ } as Partial<PreparePayResult>),
getBalance: async () =>
- ({
- balances: [
- {
- available: "USD:5",
- },
- ],
- } as Partial<BalancesResponse>),
+ ({
+ balances: [
+ {
+ available: "USD:5",
+ },
+ ],
+ } as Partial<BalancesResponse>),
} as Partial<typeof wxApi> as any,
),
);
@@ -198,23 +201,24 @@ describe("Payment CTA states", () => {
talerPayUri: "taller://pay",
cancel: nullFunction,
goToWalletManualWithdraw: nullFunction,
+ onSuccess: async () => { null; },
},
{
onUpdateNotification: nullFunction,
preparePay: async () =>
- ({
- amountRaw: "USD:10",
- amountEffective: "USD:10",
- status: PreparePayResultType.PaymentPossible,
- } as Partial<PreparePayResult>),
+ ({
+ amountRaw: "USD:10",
+ amountEffective: "USD:10",
+ status: PreparePayResultType.PaymentPossible,
+ } as Partial<PreparePayResult>),
getBalance: async () =>
- ({
- balances: [
- {
- available: "USD:15",
- },
- ],
- } as Partial<BalancesResponse>),
+ ({
+ balances: [
+ {
+ available: "USD:15",
+ },
+ ],
+ } as Partial<BalancesResponse>),
} as Partial<typeof wxApi> as any,
),
);
@@ -247,23 +251,24 @@ describe("Payment CTA states", () => {
talerPayUri: "taller://pay",
cancel: nullFunction,
goToWalletManualWithdraw: nullFunction,
+ onSuccess: async () => { null; },
},
{
onUpdateNotification: nullFunction,
preparePay: async () =>
- ({
- amountRaw: "USD:9",
- amountEffective: "USD:10",
- status: PreparePayResultType.PaymentPossible,
- } as Partial<PreparePayResult>),
+ ({
+ amountRaw: "USD:9",
+ amountEffective: "USD:10",
+ status: PreparePayResultType.PaymentPossible,
+ } as Partial<PreparePayResult>),
getBalance: async () =>
- ({
- balances: [
- {
- available: "USD:15",
- },
- ],
- } as Partial<BalancesResponse>),
+ ({
+ balances: [
+ {
+ available: "USD:15",
+ },
+ ],
+ } as Partial<BalancesResponse>),
} as Partial<typeof wxApi> as any,
),
);
@@ -296,28 +301,29 @@ describe("Payment CTA states", () => {
talerPayUri: "taller://pay",
cancel: nullFunction,
goToWalletManualWithdraw: nullFunction,
+ onSuccess: async () => { null; },
},
{
onUpdateNotification: nullFunction,
preparePay: async () =>
- ({
- amountRaw: "USD:9",
- amountEffective: "USD:10",
- status: PreparePayResultType.PaymentPossible,
- } as Partial<PreparePayResult>),
+ ({
+ amountRaw: "USD:9",
+ amountEffective: "USD:10",
+ status: PreparePayResultType.PaymentPossible,
+ } as Partial<PreparePayResult>),
getBalance: async () =>
- ({
- balances: [
- {
- available: "USD:15",
- },
- ],
- } as Partial<BalancesResponse>),
+ ({
+ balances: [
+ {
+ available: "USD:15",
+ },
+ ],
+ } as Partial<BalancesResponse>),
confirmPay: async () =>
- ({
- type: ConfirmPayResultType.Done,
- contractTerms: {},
- } as Partial<ConfirmPayResult>),
+ ({
+ type: ConfirmPayResultType.Done,
+ contractTerms: {},
+ } as Partial<ConfirmPayResult>),
} as Partial<typeof wxApi> as any,
),
);
@@ -340,18 +346,18 @@ describe("Payment CTA states", () => {
r.payHandler.onClick();
}
- await waitNextUpdate();
+ // await waitNextUpdate();
- {
- const r = getLastResultOrThrow();
- if (r.status !== "completed") expect.fail();
- expect(r.balance).deep.equal(Amounts.parseOrThrow("USD:15"));
- expect(r.amount).deep.equal(Amounts.parseOrThrow("USD:9"));
- // expect(r.totalFees).deep.equal(Amounts.parseOrThrow("USD:1"));
- // if (r.payResult.type !== ConfirmPayResultType.Done) expect.fail();
- // expect(r.payResult.contractTerms).not.undefined;
- // expect(r.payHandler.onClick).undefined;
- }
+ // {
+ // const r = getLastResultOrThrow();
+ // if (r.status !== "completed") expect.fail();
+ // expect(r.balance).deep.equal(Amounts.parseOrThrow("USD:15"));
+ // expect(r.amount).deep.equal(Amounts.parseOrThrow("USD:9"));
+ // // expect(r.totalFees).deep.equal(Amounts.parseOrThrow("USD:1"));
+ // // if (r.payResult.type !== ConfirmPayResultType.Done) expect.fail();
+ // // expect(r.payResult.contractTerms).not.undefined;
+ // // expect(r.payHandler.onClick).undefined;
+ // }
await assertNoPendingUpdate();
});
@@ -364,28 +370,29 @@ describe("Payment CTA states", () => {
talerPayUri: "taller://pay",
cancel: nullFunction,
goToWalletManualWithdraw: nullFunction,
+ onSuccess: async () => { null; },
},
{
onUpdateNotification: nullFunction,
preparePay: async () =>
- ({
- amountRaw: "USD:9",
- amountEffective: "USD:10",
- status: PreparePayResultType.PaymentPossible,
- } as Partial<PreparePayResult>),
+ ({
+ amountRaw: "USD:9",
+ amountEffective: "USD:10",
+ status: PreparePayResultType.PaymentPossible,
+ } as Partial<PreparePayResult>),
getBalance: async () =>
- ({
- balances: [
- {
- available: "USD:15",
- },
- ],
- } as Partial<BalancesResponse>),
+ ({
+ balances: [
+ {
+ available: "USD:15",
+ },
+ ],
+ } as Partial<BalancesResponse>),
confirmPay: async () =>
- ({
- type: ConfirmPayResultType.Pending,
- lastError: { code: 1 },
- } as Partial<ConfirmPayResult>),
+ ({
+ type: ConfirmPayResultType.Pending,
+ lastError: { code: 1 },
+ } as Partial<ConfirmPayResult>),
} as Partial<typeof wxApi> as any,
),
);
@@ -447,23 +454,24 @@ describe("Payment CTA states", () => {
talerPayUri: "taller://pay",
cancel: nullFunction,
goToWalletManualWithdraw: nullFunction,
+ onSuccess: async () => { null; },
},
{
onUpdateNotification: subscriptions.saveSubscription,
preparePay: async () =>
- ({
- amountRaw: "USD:9",
- amountEffective: "USD:10",
- status: PreparePayResultType.PaymentPossible,
- } as Partial<PreparePayResult>),
+ ({
+ amountRaw: "USD:9",
+ amountEffective: "USD:10",
+ status: PreparePayResultType.PaymentPossible,
+ } as Partial<PreparePayResult>),
getBalance: async () =>
- ({
- balances: [
- {
- available: Amounts.stringify(availableBalance),
- },
- ],
- } as Partial<BalancesResponse>),
+ ({
+ balances: [
+ {
+ available: Amounts.stringify(availableBalance),
+ },
+ ],
+ } as Partial<BalancesResponse>),
} as Partial<typeof wxApi> as any,
),
);