Files
WebODF/node_modules/karma-webodf/lib/adapter.js
T

49 lines
1.6 KiB
JavaScript
Raw Normal View History

2013-12-12 15:59:30 +01:00
/*global window, tester, tests, runNextTest, runtime*/
/*jslint nomen: true, emptyblock: true, unparam: true*/
(function (win) {
"use strict";
// signal to UnitTester that the tests should not start automatically.
win.use_karma = true;
/**
* Returned start function is invoked by Karma runner when Karma is
* ready (connected with a browser and loaded all the required files)
*
* @param {Object} karma Karma runner instance
* @return {Function} start function
*/
function createStartFn(karma) {
return function () {
2013-12-12 19:50:53 +01:00
var testCount = 0;
2013-12-12 15:59:30 +01:00
tester.resourcePrefix = "tests/";
2013-12-12 19:50:53 +01:00
tester.reporter = function (r) {
testCount += 1;
karma.info({total: testCount});
karma.result(r);
};
2013-12-12 15:59:30 +01:00
// tell karma how many tests there are
2013-12-12 19:50:53 +01:00
karma.info({total: testCount});
2013-12-12 15:59:30 +01:00
runNextTest(tests, tester, function () {
// tell karma to end the run
karma.complete({
coverage: window.__coverage__
});
});
};
}
/**
* Returned function is used for logging by Karma
*/
function createDumpFn(karma, serialize) {
// inside you could use a custom `serialize` function
// to modify or attach messages or hook into logging
return function () {
karma.info({ dump: [].slice.call(arguments) });
};
}
win.__karma__.start = createStartFn(window.__karma__);
win.dump = createDumpFn(win.__karma__, function (value) {
return value;
});
}(window));