gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant-backoffice] 05/11: bank: make tests 'Content-Type' aware


From: gnunet
Subject: [taler-merchant-backoffice] 05/11: bank: make tests 'Content-Type' aware
Date: Mon, 20 Dec 2021 17:45:03 +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 a0906777d7dc44de58d5572dcbb571d8432a639f
Author: ms <ms@taler.net>
AuthorDate: Sun Dec 19 14:27:01 2021 +0100

    bank: make tests 'Content-Type' aware
---
 packages/bank/src/pages/home/index.tsx    | 15 ++++++++++++++-
 packages/bank/tests/__tests__/homepage.js | 10 ++++++----
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/packages/bank/src/pages/home/index.tsx 
b/packages/bank/src/pages/home/index.tsx
index 7700a9d..71debe4 100644
--- a/packages/bank/src/pages/home/index.tsx
+++ b/packages/bank/src/pages/home/index.tsx
@@ -170,6 +170,10 @@ async function confirmWithdrawalCall(
       "Authorization",
       `Basic ${Buffer.from(backendState.username + ":" + 
backendState.password).toString("base64")}`
     );
+    headers.append(
+      "Content-Type",
+      "application/json"
+    )
     // Backend URL must have been stored _with_ a final slash.
     const url = new URL(
       `access-api/accounts/${backendState.username}/withdrawals/confirm`,
@@ -245,6 +249,10 @@ async function createWithdrawalCall(
       "Authorization",
       `Basic ${Buffer.from(backendState.username + ":" + 
backendState.password).toString("base64")}`
     );
+    headers.append(
+      "Content-Type",
+      "application/json"
+    )
     // Backend URL must have been stored _with_ a final slash.
     const url = new URL(
       `access-api/accounts/${backendState.username}/withdrawals`,
@@ -337,12 +345,17 @@ async function registrationCall(
   if (!baseUrl.endsWith('/')) {
     baseUrl += '/'
   }
-  let headersNoCache = new Headers();
+  let headers = new Headers();
+  headers.append(
+    "Content-Type",
+    "application/json"
+  )
   const url = new URL("access-api/testing/register", baseUrl)
   try {
     var res = await fetch(url.href, {
       method: 'POST',
       body: JSON.stringify(req),
+      headers: headers
     });
   } catch (error) {
     console.log("Could not POST new registration to the bank", error);
diff --git a/packages/bank/tests/__tests__/homepage.js 
b/packages/bank/tests/__tests__/homepage.js
index b677ed1..5508453 100644
--- a/packages/bank/tests/__tests__/homepage.js
+++ b/packages/bank/tests/__tests__/homepage.js
@@ -162,8 +162,9 @@ describe("home page", () => {
     await screen.findByText("has a problem", {exact: false});
     expect(fetch).toHaveBeenCalledWith(
       "http://localhost/demobanks/default/access-api/testing/register";,
-      {body: JSON.stringify({username: username, password: "bar"}), method: 
"POST"},
-    )
+      expect.objectContaining(
+        {body: JSON.stringify({username: username, password: "bar"}), method: 
"POST"},
+    ))
   })
 
   test("registration network failure", async () => {
@@ -175,8 +176,9 @@ describe("home page", () => {
     await screen.findByText("has a problem", {exact: false});
     expect(fetch).toHaveBeenCalledWith(
       "http://localhost/demobanks/default/access-api/testing/register";,
-      {body: JSON.stringify({username: username, password: "bar"}), method: 
"POST"},
-    )
+      expect.objectContaining(
+        {body: JSON.stringify({username: username, password: "bar"}), method: 
"POST"}
+      ))
   })
   
   test("login non existent user", async () => {

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