gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant-backoffice] 03/11: bank tests


From: gnunet
Subject: [taler-merchant-backoffice] 03/11: bank tests
Date: Mon, 20 Dec 2021 17:45:01 +0100

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

ms pushed a commit to branch master
in repository merchant-backoffice.

commit 2981b6e16925af7a40caa25c3a8d7c741e0630c3
Author: ms <ms@taler.net>
AuthorDate: Sun Dec 19 09:09:17 2021 +0100

    bank tests
    
    mocking Sandbox default 'demobank' base URL
---
 packages/bank/src/pages/home/index.tsx    |  8 ++++----
 packages/bank/tests/__tests__/homepage.js | 22 ++++++++++++++++++----
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/packages/bank/src/pages/home/index.tsx 
b/packages/bank/src/pages/home/index.tsx
index f7b0f51..d3ec261 100644
--- a/packages/bank/src/pages/home/index.tsx
+++ b/packages/bank/src/pages/home/index.tsx
@@ -171,7 +171,7 @@ async function confirmWithdrawalCall(
       `Basic ${Buffer.from(backendState.username + ":" + 
backendState.password).toString("base64")}`
     );
     var res = await fetch(
-      
`${backendState.url}accounts/${backendState.username}/withdrawals/confirm`, {
+      
`${backendState.url}/accounts/${backendState.username}/withdrawals/confirm`, {
         method: 'POST',
        headers: headers
     })
@@ -242,7 +242,7 @@ async function createWithdrawalCall(
       `Basic ${Buffer.from(backendState.username + ":" + 
backendState.password).toString("base64")}`
     );
     var res = await fetch(
-      `${backendState.url}accounts/${backendState.username}/withdrawals`, {
+      `${backendState.url}/accounts/${backendState.username}/withdrawals`, {
         method: 'POST',
        headers: headers,
        body: JSON.stringify({amount: amount}),
@@ -324,7 +324,7 @@ async function registrationCall(
   let headersNoCache = new Headers();
   try {
     var res = await fetch(
-      `${baseUrl}testing/register`, {
+      `${baseUrl}/testing/register`, {
       method: 'POST',
       body: JSON.stringify(req),
     });
@@ -362,7 +362,7 @@ async function registrationCall(
  */
 function Account(props: any) {
   const { withdrawalOutcome, talerWithdrawUri, accountLabel } = props;
-  const { data, error } = useSWR(`accounts/${props.accountLabel}`);
+  const { data, error } = useSWR(`/accounts/${props.accountLabel}`);
   console.log("account data", data);
   console.log("account error", error);
   if (typeof error !== "undefined") {
diff --git a/packages/bank/tests/__tests__/homepage.js 
b/packages/bank/tests/__tests__/homepage.js
index 645c733..a33088b 100644
--- a/packages/bank/tests/__tests__/homepage.js
+++ b/packages/bank/tests/__tests__/homepage.js
@@ -7,6 +7,16 @@ import { waitFor, cleanup, render, fireEvent, screen } from 
'@testing-library/pr
 import expect from 'expect';
 import fetchMock from "jest-fetch-mock";
 
+
+beforeAll(() => {
+  Object.defineProperty(window, 'location', {
+    value: {
+      origin: "http://localhost";,
+      pathname: "/demobanks/default"
+    }
+  })
+})
+
 /**
  * Insert username and password into the registration
  * form and returns the submit button.  NOTE: the username
@@ -86,7 +96,7 @@ describe("withdraw", () => {
      */
     fireEvent.click(withdrawButton);
     expect(fetch).toHaveBeenCalledWith(
-      `http://localhost/accounts/${context.username}/withdrawals`,
+      
`http://localhost/demobanks/default/accounts/${context.username}/withdrawals`,
       expect.objectContaining({body: JSON.stringify({amount: "EUR:5"})})
     )
     await screen.findByText("give this address to", {exact: false})
@@ -151,7 +161,7 @@ describe("home page", () => {
     fireEvent.click(signupButton);
     await screen.findByText("has a problem", {exact: false});
     expect(fetch).toHaveBeenCalledWith(
-      "http://localhost/testing/register";,
+      "http://localhost/demobanks/default/testing/register";,
       {body: JSON.stringify({username: username, password: "bar"}), method: 
"POST"},
     )
   })
@@ -164,7 +174,7 @@ describe("home page", () => {
     fireEvent.click(signupButton);
     await screen.findByText("has a problem", {exact: false});
     expect(fetch).toHaveBeenCalledWith(
-      "http://localhost/testing/register";,
+      "http://localhost/demobanks/default/testing/register";,
       {body: JSON.stringify({username: username, password: "bar"}), method: 
"POST"},
     )
   })
@@ -222,8 +232,12 @@ describe("home page", () => {
      * The expectation below tests whether the account
      * balance was requested after the successful registration.
      */
+    expect(fetch).toHaveBeenCalledWith(
+      "http://localhost/demobanks/default/testing/register";,
+      expect.anything() // no need to match auth headers.
+    )
     expect(fetch).toHaveBeenLastCalledWith(
-      `http://localhost/accounts/${username}`,
+      `http://localhost/demobanks/default/accounts/${username}`,
       expect.anything() // no need to match auth headers.
     )
   })

-- 
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]