gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-backoffice] branch master updated: non-working "/tra


From: gnunet
Subject: [GNUnet-SVN] [taler-backoffice] branch master updated: non-working "/track/transfer" test case
Date: Thu, 11 Jan 2018 16:04:01 +0100

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

marcello pushed a commit to branch master
in repository backoffice.

The following commit(s) were added to refs/heads/master by this push:
     new 956e3e4  non-working "/track/transfer" test case
956e3e4 is described below

commit 956e3e4dfa26dda986ad9ed90ce64cf537a12e7f
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Jan 11 16:03:31 2018 +0100

    non-working "/track/transfer" test case
---
 js/backoffice.js | 22 +++++++++++++---------
 js/test/main.js  | 29 ++++++++++++++++++++++++++++-
 2 files changed, 41 insertions(+), 10 deletions(-)

diff --git a/js/backoffice.js b/js/backoffice.js
index 1c1b1fa..c5524e1 100644
--- a/js/backoffice.js
+++ b/js/backoffice.js
@@ -57,6 +57,7 @@ function close_popup(){
 
   toggle_overlay(true);
 }
+module.exports.close_popup = close_popup;
 
 function amount_sum(a1, a2){
   if(a1.currency != a2.currency)
@@ -129,14 +130,11 @@ function track_transfer(exchange, wtid){
       case 200:
         var tracks = JSON.parse(req.responseText);
         clean_results();
+        /**
+         * close the popup which is now on the focus showing
+         * the tracks from one order. */
         close_popup();
-        fill_table(tracks.deposits_sums, tracks.execution_time);
-
-        // draw a line @ the bottom, mentioning the WTID.
-        var table = document.getElementById("history");
-        var tbody = xpath_get("tbody", table).snapshotItem(0);
-        var marker = make_marker(wtid);
-        tbody.appendChild(marker);
+        fill_table(tracks.deposits_sums, tracks.execution_time, wtid);
         break;
       case 400:
         console.log("Bad request, check submitted data!");
@@ -148,6 +146,7 @@ function track_transfer(exchange, wtid){
   }
   req.send();
 }
+module.exports.track_transfer = track_transfer;
 
 function track_order(order_id){
   var req = new XMLHttpRequest();
@@ -219,7 +218,7 @@ function xpath_get(xpath, ctx){
 /**
  * Append results to the table showing results.
  */
-function fill_table(history, execution_time){
+function fill_table(history, execution_time, wtid_marker){
   var table = document.getElementById("history");
   var tbody = xpath_get("tbody", table).snapshotItem(0);
   var nr = xpath_get("address@hidden'no-records']", tbody).snapshotItem(0)
@@ -265,7 +264,11 @@ function fill_table(history, execution_time){
     tbody.appendChild(row);
     tbody.appendChild(row_summary);
     }
-
+  if (wtid_marker){
+    // draw a line @ the bottom, mentioning the WTID.
+    var marker = make_marker(wtid_marker);
+    tbody.appendChild(marker);
+  }
   function remove_loader(){
     var loader = document.getElementsByClassName("loader")[0]; 
     loader.style.visibility = "hidden";
@@ -273,6 +276,7 @@ function fill_table(history, execution_time){
   }
   window.setTimeout(remove_loader, 900);
 }
+module.exports.fill_table = fill_table;
 
 /**
  * Issue a direrct /track via Web form.
diff --git a/js/test/main.js b/js/test/main.js
index 13ec0d5..66c715b 100644
--- a/js/test/main.js
+++ b/js/test/main.js
@@ -72,9 +72,36 @@ ava.test.afterEach(t => {
   delete global.alert;
   delete t.context.xhr;
   delete t.context.requests;
+  var bo_handle = require.resolve("../backoffice");
+  delete require.cache[bo_handle];
 });
 
-ava.test("Tracking order id", (t) => {
+ava.test("Tracking a wire transfer", (t) => {
+  /**
+   * This test case checks whether the popup where
+   * the user clicked to track a wire transfer got
+   * closed; then it checks that the 'table' of the
+   * orders associated with this wire transfer got
+   * correctly filled.
+   */
+
+  var mock_tracks = {
+    deposits_sums: ["mock-tracks"],
+    execution_time: "/Date(0)/"};
+
+  sinon.stub(t.context.bo, "close_popup"); 
+  sinon.stub(t.context.bo, "fill_table"); 
+  t.context.bo.track_transfer("http://exchange.mock/";, "mock-wtid");
+  t.context.requests[0].respond(200, "application/json",
+                                JSON.stringify(mock_tracks));
+  sinon.assert.calledOnce(t.context.bo.close_popup);
+  sinon.assert.calledWith(t.context.bo.fill_table,
+                          ["mock-tracks"],
+                          "/Date(0)/",
+                          "mock-wtid");
+});
+
+ava.test("Tracking order id", t => {
 
   /**
    * This test case checks whether the 'overlay' element in the

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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