diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-02-29 18:03:02 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-02-29 18:03:02 +0100 |
commit | c962e9402123900c53967c14cf809ea10576cdb8 (patch) | |
tree | e7df9cfdd6fceae30fb99c8ec6be5e07c8b153a8 /test | |
parent | 30ee3320c788129b258ed8b42f4fc63d28431e2f (diff) | |
download | wallet-core-c962e9402123900c53967c14cf809ea10576cdb8.tar.xz |
restructure
Diffstat (limited to 'test')
-rw-r--r-- | test/run_tests.js | 55 | ||||
-rw-r--r-- | test/tests/taler.ts | 24 |
2 files changed, 79 insertions, 0 deletions
diff --git a/test/run_tests.js b/test/run_tests.js new file mode 100644 index 000000000..f62810f7e --- /dev/null +++ b/test/run_tests.js @@ -0,0 +1,55 @@ + +/** + * Bridge between the mocha test runner / nodejs + * and the typescript / the wallet's module system. + * + * The test cases use better-assert as assert library + * with mocha's bdd UI. + */ + +"use strict"; + +let assert = require("better-assert"); +let vm = require("vm"); +let fs = require("fs"); + + +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 data = fs.readFileSync("lib/emscripten/libwrapper.js"); +vm.runInThisContext(data); + +// Do it here, since it breaks 'require'' +let System = require("systemjs"); + +System.config({ + defaultJSExtensions: true +}); + +let mod = System.newModule({Module: Module}); +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(); + }) + .catch((e) => { + console.error("failed to load module", e.stack); + }); + + diff --git a/test/tests/taler.ts b/test/tests/taler.ts new file mode 100644 index 000000000..14130f9af --- /dev/null +++ b/test/tests/taler.ts @@ -0,0 +1,24 @@ +import * as Emsc from '../../lib/wallet/emscriptif'; + + +declare var HttpMockLib; + +export function declareTests(assert, context, it) { + + it("works!", 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 |