summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2018-01-11 16:03:31 +0100
committerMarcello Stanisci <stanisci.m@gmail.com>2018-01-11 16:03:31 +0100
commit956e3e4dfa26dda986ad9ed90ce64cf537a12e7f (patch)
treed3d8d1413a446587c57ffbab68677d70b5b82425
parentcba3fa0f0280c6bc4a79c4a6233a9f7a47906a03 (diff)
downloadbackoffice-956e3e4dfa26dda986ad9ed90ce64cf537a12e7f.tar.gz
backoffice-956e3e4dfa26dda986ad9ed90ce64cf537a12e7f.tar.bz2
backoffice-956e3e4dfa26dda986ad9ed90ce64cf537a12e7f.zip
non-working "/track/transfer" test case
-rw-r--r--js/backoffice.js22
-rw-r--r--js/test/main.js29
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("tr[@class='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