From caa9a22d6970df331eebed032b9a9673d4217fc6 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Mon, 6 Dec 2021 15:27:20 -0300
Subject: check timeout when doing a query to /keys to add an exchange

---
 .../src/wallet/ExchangeAddSetUrl.stories.tsx       | 40 +++++++++++++---------
 1 file changed, 23 insertions(+), 17 deletions(-)

(limited to 'packages/taler-wallet-webextension/src/wallet/ExchangeAddSetUrl.stories.tsx')

diff --git a/packages/taler-wallet-webextension/src/wallet/ExchangeAddSetUrl.stories.tsx b/packages/taler-wallet-webextension/src/wallet/ExchangeAddSetUrl.stories.tsx
index 9ea800fe4..6f0a58729 100644
--- a/packages/taler-wallet-webextension/src/wallet/ExchangeAddSetUrl.stories.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/ExchangeAddSetUrl.stories.tsx
@@ -36,33 +36,39 @@ export default {
 export const ExpectedUSD = createExample(TestedComponent, {
   expectedCurrency: "USD",
   onVerify: queryToSlashKeys,
-  knownExchanges: [],
 });
 
 export const ExpectedKUDOS = createExample(TestedComponent, {
   expectedCurrency: "KUDOS",
   onVerify: queryToSlashKeys,
-  knownExchanges: [],
 });
 
 export const InitialState = createExample(TestedComponent, {
   onVerify: queryToSlashKeys,
-  knownExchanges: [],
 });
 
-export const WithDemoAsKnownExchange = createExample(TestedComponent, {
-  knownExchanges: [
-    {
-      currency: "TESTKUDOS",
-      exchangeBaseUrl: "https://exchange.demo.taler.net/",
-      tos: {
-        currentVersion: "1",
-        acceptedVersion: "1",
-        content: "content of tos",
-        contentType: "text/plain",
-      },
-      paytoUris: [],
+const knownExchanges = [
+  {
+    currency: "TESTKUDOS",
+    exchangeBaseUrl: "https://exchange.demo.taler.net/",
+    tos: {
+      currentVersion: "1",
+      acceptedVersion: "1",
+      content: "content of tos",
+      contentType: "text/plain",
     },
-  ],
-  onVerify: queryToSlashKeys,
+    paytoUris: [],
+  },
+];
+
+export const WithDemoAsKnownExchange = createExample(TestedComponent, {
+  onVerify: async (url) => {
+    const found =
+      knownExchanges.findIndex((e) => e.exchangeBaseUrl === url) !== -1;
+
+    if (found) {
+      throw Error("This exchange is already known");
+    }
+    return queryToSlashKeys(url);
+  },
 });
-- 
cgit v1.2.3

