gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: making test pass


From: gnunet
Subject: [taler-wallet-core] branch master updated: making test pass
Date: Mon, 17 Oct 2022 15:52:26 +0200

This is an automated email from the git hooks/post-receive script.

sebasjm pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new fd3278f4c making test pass
fd3278f4c is described below

commit fd3278f4c681fb60c6f791ab6fa066f9a524478a
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Mon Oct 17 10:18:17 2022 -0300

    making test pass
---
 .../src/cta/Withdraw/index.ts                      |  8 ++--
 .../src/cta/Withdraw/state.ts                      |  7 ++--
 .../src/cta/Withdraw/test.ts                       | 49 +++++++++++++---------
 3 files changed, 38 insertions(+), 26 deletions(-)

diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/index.ts 
b/packages/taler-wallet-webextension/src/cta/Withdraw/index.ts
index 075b21dc3..a3b3df8b3 100644
--- a/packages/taler-wallet-webextension/src/cta/Withdraw/index.ts
+++ b/packages/taler-wallet-webextension/src/cta/Withdraw/index.ts
@@ -56,11 +56,11 @@ export namespace State {
     error: undefined;
   }
   export interface LoadingUriError {
-    status: "loading-error";
+    status: "uri-error";
     error: HookError;
   }
   export interface LoadingInfoError {
-    status: "loading-info";
+    status: "amount-error";
     error: HookError;
   }
 
@@ -87,8 +87,8 @@ export namespace State {
 
 const viewMapping: StateViewMap<State> = {
   loading: Loading,
-  "loading-error": LoadingUriView,
-  "loading-info": LoadingInfoView,
+  "uri-error": LoadingUriView,
+  "amount-error": LoadingInfoView,
   "no-exchange": NoExchangesView,
   "selecting-exchange": ExchangeSelectionPage,
   success: SuccessView,
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts 
b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts
index f4aea9cd6..c542d8aae 100644
--- a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts
+++ b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts
@@ -43,7 +43,7 @@ export function useComponentStateFromParams(
 
   if (uriInfoHook.hasError) {
     return {
-      status: "loading-error",
+      status: "uri-error",
       error: uriInfoHook,
     };
   }
@@ -110,7 +110,7 @@ export function useComponentStateFromURI(
 
   if (uriInfoHook.hasError) {
     return {
-      status: "loading-error",
+      status: "uri-error",
       error: uriInfoHook,
     };
   }
@@ -180,6 +180,7 @@ function exchangeSelectionState(
     const tosNeedToBeAccepted =
       currentExchange.tosStatus == ExchangeTosStatus.New ||
       currentExchange.tosStatus == ExchangeTosStatus.Changed;
+
     /**
      * With the exchange and amount, ask the wallet the information
      * about the withdrawal
@@ -232,7 +233,7 @@ function exchangeSelectionState(
     }
     if (amountHook.hasError) {
       return {
-        status: "loading-info",
+        status: "amount-error",
         error: amountHook,
       };
     }
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts 
b/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts
index 2b0690800..977faa03a 100644
--- a/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts
+++ b/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts
@@ -21,23 +21,26 @@
 
 import {
   Amounts,
+  ExchangeEntryStatus,
   ExchangeFullDetails,
+  ExchangeListItem,
+  ExchangesListResponse,
   ExchangeTosStatus,
   GetExchangeTosResult,
+  ManualWithdrawalDetails,
 } from "@gnu-taler/taler-util";
 import { expect } from "chai";
 import { mountHook } from "../../test-utils.js";
 import { useComponentStateFromURI } from "./state.js";
 
-const exchanges: ExchangeFullDetails[] = [
+const exchanges: ExchangeListItem[] = [
   {
     currency: "ARS",
     exchangeBaseUrl: "http://exchange.demo.taler.net";,
     paytoUris: [],
-    tos: {
-      acceptedVersion: "v1",
-      currentVersion: "v1",
-    },
+    tosStatus: ExchangeTosStatus.Accepted,
+    exchangeStatus: ExchangeEntryStatus.Ok,
+    permanent: true,
     auditors: [
       {
         auditor_pub: "pubpubpubpubpub",
@@ -57,7 +60,7 @@ const exchanges: ExchangeFullDetails[] = [
       accounts: [],
       feesForType: {},
     },
-  } as Partial<ExchangeFullDetails> as ExchangeFullDetails,
+  } as Partial<ExchangeListItem> as ExchangeListItem,
 ];
 
 describe("Withdraw CTA states", () => {
@@ -76,7 +79,9 @@ describe("Withdraw CTA states", () => {
           },
           {
             listExchanges: async () => ({ exchanges }),
-            getWithdrawalDetailsForUri: async ({ talerWithdrawUri }: any) => ({
+            getWithdrawalDetailsForAmount: async ({
+              talerWithdrawUri,
+            }: any) => ({
               amount: "ARS:2",
               possibleExchanges: exchanges,
             }),
@@ -94,7 +99,7 @@ describe("Withdraw CTA states", () => {
     {
       const { status, error } = getLastResultOrThrow();
 
-      if (status != "loading-error") expect.fail();
+      if (status != "uri-error") expect.fail();
       if (!error) expect.fail();
       if (!error.hasError) expect.fail();
       if (error.operational) expect.fail();
@@ -165,6 +170,12 @@ describe("Withdraw CTA states", () => {
               possibleExchanges: exchanges,
               defaultExchangeBaseUrl: exchanges[0].exchangeBaseUrl,
             }),
+            getWithdrawalDetailsForAmount:
+              async (): Promise<ManualWithdrawalDetails> =>
+                ({
+                  amountRaw: "ARS:2",
+                  amountEffective: "ARS:2",
+                } as any),
             getExchangeTos: async (): Promise<GetExchangeTosResult> => ({
               contentType: "text",
               content: "just accept",
@@ -210,24 +221,18 @@ describe("Withdraw CTA states", () => {
   });
 
   it("should be accept the tos before withdraw", async () => {
-    const listExchangesResponse = {
+    const listExchangesResponse: ExchangesListResponse = {
       exchanges: exchanges.map((e) => ({
         ...e,
-        tos: {
-          ...e.tos,
-          acceptedVersion: undefined,
-        },
-      })) as ExchangeFullDetails[],
+        tosStatus: ExchangeTosStatus.New,
+      })),
     };
 
     function updateAcceptedVersionToCurrentVersion(): void {
       listExchangesResponse.exchanges = listExchangesResponse.exchanges.map(
         (e) => ({
           ...e,
-          tos: {
-            ...e.tos,
-            acceptedVersion: e.tos.currentVersion,
-          },
+          tosStatus: ExchangeTosStatus.Accepted,
         }),
       );
     }
@@ -245,12 +250,18 @@ describe("Withdraw CTA states", () => {
             },
           },
           {
-            listExchanges: async () => ({ exchanges }),
+            listExchanges: async () => listExchangesResponse,
             getWithdrawalDetailsForUri: async ({ talerWithdrawUri }: any) => ({
               amount: "ARS:2",
               possibleExchanges: exchanges,
               defaultExchangeBaseUrl: exchanges[0].exchangeBaseUrl,
             }),
+            getWithdrawalDetailsForAmount:
+              async (): Promise<ManualWithdrawalDetails> =>
+                ({
+                  amountRaw: "ARS:2",
+                  amountEffective: "ARS:2",
+                } as any),
             getExchangeTos: async (): Promise<GetExchangeTosResult> => ({
               contentType: "text",
               content: "just accept",

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]