Report the number of tests

This commit is contained in:
Caleb James DeLisle 2017-12-21 10:40:48 +01:00
parent c928be028a
commit 4117eb71cc

View file

@ -4,9 +4,11 @@ define([], function () {
var locks = []; var locks = [];
var tests = []; var tests = [];
var failed = false; var failed = false;
var totalTests = 0;
var out = window.__CRYPTPAD_TEST_OBJ__ = function (f) { var out = window.__CRYPTPAD_TEST_OBJ__ = function (f) {
if (!out.testing) { return; } if (!out.testing) { return; }
tests.push(f); tests.push(f);
totalTests++;
var runLock = function (lock) { var runLock = function (lock) {
lock(function () { setTimeout(function () { runLock(locks.shift()); }); }); lock(function () { setTimeout(function () { runLock(locks.shift()); }); });
}; };
@ -18,7 +20,10 @@ define([], function () {
throw new Error("Pass called on an unknown test (called multiple times?)"); throw new Error("Pass called on an unknown test (called multiple times?)");
} }
tests.splice(i, 1); tests.splice(i, 1);
if (!tests.length) { out.passed(); } if (!tests.length) {
console.log("Completed " + totalTests + " successfully");
out.passed();
}
}, },
fail: function (reason) { fail: function (reason) {
failed = true; failed = true;