Fixed timeouts

This commit is contained in:
Martin Schröder 2015-05-22 13:09:35 +02:00 committed by Martin Schröder
parent 0ffd48cef5
commit 65eb4701ca
5 changed files with 12 additions and 17 deletions

View file

@ -84,7 +84,7 @@ module.exports = function(grunt){
});
});
grunt.registerTask("test", "Run all tests using mocha", function(){
var files = grunt.file.expand(["./tests/test-*.js", "./htdocs/**/test-*.js"]);
var files = grunt.file.expand(["./tests/test-*.js", "./htdocs/**/test-*.js", "./htdocs/**/*.test.js"]);
console.log("Will run tests: "+files);
var done = this.async();
var spawn = require('child_process').spawn;

View file

@ -13,21 +13,19 @@
repeat: function(name, t, fn){
function _onTimeout(){
fn(function next(ret, err){
if(ret){
clearTimeout(i);
delete _timeouts[name];
} else {
// restart the timeout if it did not exit
setTimeout(_onTimeout, t);
if(!ret) {
if(!_timeouts[name] || !_timeouts[name].cleared)
_timeouts[name] = setTimeout(_onTimeout, t);
}
});
}
var i = setTimeout(_onTimeout, t); _onTimeout();
_timeouts[name] = i;
//_timeouts[name] = setTimeout(_onTimeout, t);
_onTimeout();
},
$clearAll: function(){
Object.keys(_timeouts).map(function(t){
clearTimeout(t);
clearTimeout(_timeouts[t]);
_timeouts[t].cleared = true;
});
}
};

View file

@ -1,4 +1,4 @@
global.JUCI = require("../../../../tests/lib-juci");
require("../../../../tests/lib-juci");
require("../dropbear");
describe("Dropbear", function(){

View file

@ -1,5 +1,5 @@
#!javascript
global.JUCI = require("../../../../tests/lib-juci");
require("../../../../tests/lib-juci");
require("../wifi");
var completed = {
@ -17,10 +17,6 @@ describe("Wireless", function(){
it("should have wireless config", function(){
expect($uci.wireless).to.be.an(Object);
});
it("should have broadcom config", function(){
expect($uci.broadcom).to.be.an(Object);
expect($uci.broadcom["@all"]).not.to.be.empty();
});
it("should have hosts config", function(){
expect($uci.hosts).to.be.ok();
});

View file

@ -59,7 +59,8 @@ function JUCIMock(){
console.log("JUCI.app.controller("+name+")");
_controllers[name] = fn;
return self.app;
}
},
config: function(){}
}
function LocalStorageMock(){
var _items = {};