aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package.json7
-rw-r--r--test/run_tests.js36
-rw-r--r--test/tests/taler.ts15
3 files changed, 24 insertions, 34 deletions
diff --git a/package.json b/package.json
index e36b22776..f86943a13 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,8 @@
"description": "",
"main": "wxwallet.js",
"scripts": {
- "test": "mocha --delay"
+ "test": "mocha --delay",
+ "test-cover": "istanbul cover -x libwrapper.js _mocha -- --delay"
},
"repository": {
"type": "git",
@@ -26,13 +27,15 @@
"gulp-tar": "^1.8.0",
"gulp-typescript": "^2.10.0",
"gulp-zip": "^3.1.0",
+ "istanbul-lib-instrument": "^1.0.0-alpha.6",
"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",
"typescript": "^1.9.0-dev.20160225",
+ "typhonjs-istanbul-instrument-jspm": "^0.1.0",
"vinyl": "^1.1.1"
}
}
diff --git a/test/run_tests.js b/test/run_tests.js
index f62810f7e..88aded741 100644
--- a/test/run_tests.js
+++ b/test/run_tests.js
@@ -12,44 +12,42 @@
let assert = require("better-assert");
let vm = require("vm");
let fs = require("fs");
-
+let instrument = require("typhonjs-istanbul-instrument-jspm").default;
if ("function" !== typeof run) {
throw Error("test must be run with 'mocha --delay ...'");
}
-console.log("typeof require (here)", typeof require);
-
-// We might need thins in the future ...
-global.nodeRequire = function (modulePath) {
- return require(modulePath);
-};
-
-global.require = global.nodeRequire;
+let emsc = require("../lib/emscripten/libwrapper.js");
-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
+ defaultJSExtensions: true,
+ meta: {
+ './test/tests/taler.js': {
+ format: 'register'
+ },
+ './lib/wallet/*': {
+ format: 'register'
+ }
+ }
});
-let mod = System.newModule({Module: Module});
+instrument(System);
+
+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
+}