From 004a0372abd42da19690d95b25ede5b0ffe10601 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 27 Apr 2016 15:06:56 +0200 Subject: [PATCH] get test skeleton working again --- package.json | 2 +- test/run_tests.js | 21 ++++----------------- test/tests/taler.ts | 15 ++------------- 3 files changed, 7 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index e36b22776..7aaeaff26 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "gulp-zip": "^3.1.0", "jed": "^1.1.0", "map-stream": "0.0.6", - "mocha": "^2.3.4", + "mocha": "^2.4.5", "po2json": "git+https://github.com/mikeedwards/po2json", "systemjs": "^0.19.14", "through2": "^2.0.1", diff --git a/test/run_tests.js b/test/run_tests.js index f62810f7e..f6a623942 100644 --- a/test/run_tests.js +++ b/test/run_tests.js @@ -18,38 +18,25 @@ if ("function" !== typeof run) { throw Error("test must be run with 'mocha --delay ...'"); } -console.log("typeof require (here)", typeof require); +let emsc = require("../lib/emscripten/libwrapper.js"); -// We might need thins in the future ... -global.nodeRequire = function (modulePath) { - return require(modulePath); -}; - -global.require = global.nodeRequire; - -let data = fs.readFileSync("lib/emscripten/libwrapper.js"); -vm.runInThisContext(data); - -// Do it here, since it breaks 'require'' +// Do it here, since it breaks 'require'' for libwrapper let System = require("systemjs"); System.config({ defaultJSExtensions: true }); -let mod = System.newModule({Module: Module}); +let mod = System.newModule({Module: emsc}); let modName = System.normalizeSync(__dirname + "/../lib/emscripten/emsc"); console.log("registering", modName); System.set(modName, mod); - System.import("./test/tests/taler.js") .then((t) => { t.declareTests(assert, context, it); - run(); + setTimeout(run, 1); }) .catch((e) => { console.error("failed to load module", e.stack); }); - - diff --git a/test/tests/taler.ts b/test/tests/taler.ts index 14130f9af..941e8284d 100644 --- a/test/tests/taler.ts +++ b/test/tests/taler.ts @@ -5,20 +5,9 @@ declare var HttpMockLib; export function declareTests(assert, context, it) { - it("works!", function() { + it("calls native emscripten code", function() { let x = new Emsc.Amount({value: 42, fraction: 42, currency: "EUR"}); let j = x.toJson(); assert("value" in j); }); - - - it("retries", function() { - let m = new HttpMockLib(); - /*m.intercept() - .matchUrlContains() - .counterEquals(0) - .count() - .sen*/ - }) - -} \ No newline at end of file +}