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: Adapt JS tests to


From: gnunet
Subject: [GNUnet-SVN] [taler-backoffice] branch master updated: Adapt JS tests to the latest logic.
Date: Mon, 04 Jun 2018 22:42:55 +0200

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 188b210  Adapt JS tests to the latest logic.
188b210 is described below

commit 188b21026024cd79a2b6942f5d9d309fd7640371
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Jun 4 22:42:30 2018 +0200

    Adapt JS tests to the latest logic.
---
 configure.ac             | 13 ++++++++++++-
 js/test/main.js          | 28 ++++++++++++++--------------
 talerbackoffice/tests.py |  2 --
 3 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/configure.ac b/configure.ac
index 934db2a..2eee4c7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,9 +39,20 @@ AC_CHECK_PROG([tsc],[tsc],[yes],[no])
 AM_CONDITIONAL([HAVE_TSC], [test "x$tsc" = xyes])
 
 #
+# Check for Yarn
+#
+AC_MSG_CHECKING([Yarn])
+yarn --version &> /dev/null
+if test $? -ne 0;
+  then
+  AC_MSG_ERROR([Please install Yarn])
+fi
+
+
+#
 # Check for minifier
 #
-AC_MSG_CHECKING([Checking for jsmin])
+AC_MSG_CHECKING([jsmin])
 python3 -m jsmin &> /dev/null
 if test $? -ne 0;
   then
diff --git a/js/test/main.js b/js/test/main.js
index d54f69f..ab02193 100644
--- a/js/test/main.js
+++ b/js/test/main.js
@@ -30,19 +30,27 @@ const ava = require("ava");
 const sinon = require("sinon");
 const pd = require("pretty-data");
 
+/* Adjusts context before each test.
+ * In practice, it (1) mocks the global XHR
+ * object, (2) nullifies addEventListener and
+ * getElementById, (3) makes alert dialogs
+ * appear as AVA logs, and (4) disables native
+ * browser logging.  Finally, (5) it imports
+ * the code to be tested.  */
 ava.test.beforeEach(t => {
-
   function xhr_mock() {
     t.context.xhr = sinon.useFakeXMLHttpRequest();
     t.context.requests = [];
     t.context.xhr.onCreate = function(xhr){
       t.context.requests.push(xhr);};
     global.XMLHttpRequest = t.context.xhr;};
-
   function minor_mocks() {
     var document = {};
     document.addEventListener = ()=>{};
-    document.getElementById = ()=>{return {value: "mock"}};
+    document.getElementById = ()=>
+      /* pacifies code that attempts
+       * to change this property anyway.  */
+      {return {style: {visibility: "hidden"}}};
     global.document = document;
     global.alert = console.log;
     // disable logging for tests
@@ -53,12 +61,9 @@ ava.test.beforeEach(t => {
   t.context.bo = require("../backoffice");
 });
 
-ava.test.afterEach(t => {
-  delete global.XMLHttpRequest;
-  delete global.alert;
-  delete t.context.xhr;
-  delete t.context.requests;
-});
+/* Both of following tests just check that the callback
+ * which is in charge of modifying the page is called
+ * with the right arguments.  */
 
 ava.test("Tracking a wire transfer", (t) => {
   var mock_tracks = {
@@ -78,11 +83,6 @@ ava.test("Tracking a wire transfer", (t) => {
 
 ava.test("Tracking order id", t => {
 
-  /**
-   * This test case checks whether the 'overlay' element in the
-   * page contains the expected tracks and it is made visible.
-   */
-
   var cb = sinon.spy();
   t.context.bo.track_order(22, cb);
 
diff --git a/talerbackoffice/tests.py b/talerbackoffice/tests.py
index 4ed870b..d7b3949 100644
--- a/talerbackoffice/tests.py
+++ b/talerbackoffice/tests.py
@@ -38,8 +38,6 @@ class BackofficeTestCase(unittest.TestCase):
         # check data is returned verbatim from the backend
         self.assertEqual(response.data, b'{}\n')
 
-
-
     @patch("requests.get")
     def test_track_transfer(self, mocked_get):
         ret = MagicMock()

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



reply via email to

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