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: grouping mocks pr


From: gnunet
Subject: [GNUnet-SVN] [taler-backoffice] branch master updated: grouping mocks preparation
Date: Wed, 10 Jan 2018 17:22:35 +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 f8cfde0  grouping mocks preparation
f8cfde0 is described below

commit f8cfde0eaa38e1bccfa5c47e6c6a8738af19cc9b
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Jan 10 17:22:01 2018 +0100

    grouping mocks preparation
---
 js/test/main.js | 43 +++++++++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/js/test/main.js b/js/test/main.js
index b714a82..2d6d618 100644
--- a/js/test/main.js
+++ b/js/test/main.js
@@ -32,33 +32,36 @@ const swig = require("swig");
 const jsdom = require("jsdom");
 
 ava.test.beforeEach(t => {
-  // Global XHR mock
-  t.context.xhr = sinon.useFakeXMLHttpRequest();
-  t.context.requests = [];
-  t.context.xhr.onCreate = function(xhr){
-    t.context.requests.push(xhr);
+
+  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 document_mock() {
+    var template = swig.compileFile(
+      __dirname + "/" + "../../" +
+      "talerbackoffice/backoffice/" +
+      "templates/backoffice.html");
+    var html = template({instances: ["mock-instance"]});
+    var dom = new jsdom.JSDOM(html);
+    dom.window.document.addEventListener = function(){};
+    global.document = dom.window.document;};
+
+  function minor_mocks() {
+    global.alert = console.log;
   };
-  global.XMLHttpRequest = t.context.xhr;
 
-  // Global 'document' mock
-  var template = swig.compileFile(
-    __dirname + "/" + "../../" +
-    "talerbackoffice/backoffice/" +
-    "templates/backoffice.html");
-  var html = template({instances: ["mock-instance"]});
-  // fixme: 'document' must be a *parsed* DOM!
-  var dom = new jsdom.JSDOM(html);
-  dom.window.document.addEventListener = function(){};
-  global.document = dom.window.document;
-  global.alert = console.log;
+  xhr_mock();
+  document_mock();
+  minor_mocks();
 
-  // Load back-office code (slows down..)
   t.context.bo = require("../backoffice");
 });
 
-// Remove mocks from global scope
 ava.test.afterEach(t => {
-  // Is this done by the garbage collector anyway?
   delete global.XMLHttpRequest;
   delete global.document;
   delete global.alert;

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



reply via email to

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