diff --git a/luciexpress/Gruntfile.js b/luciexpress/Gruntfile.js index bbe422d7d..a1979120a 100644 --- a/luciexpress/Gruntfile.js +++ b/luciexpress/Gruntfile.js @@ -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; diff --git a/luciexpress/htdocs/js/timeout.js b/luciexpress/htdocs/js/timeout.js index 263e82595..571574049 100644 --- a/luciexpress/htdocs/js/timeout.js +++ b/luciexpress/htdocs/js/timeout.js @@ -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; }); } }; diff --git a/luciexpress/htdocs/plugins/juci-mod-dropbear/tests/test-dropbear.js b/luciexpress/htdocs/plugins/juci-mod-dropbear/tests/test-dropbear.js index c92c14c6d..ea87b56e4 100644 --- a/luciexpress/htdocs/plugins/juci-mod-dropbear/tests/test-dropbear.js +++ b/luciexpress/htdocs/plugins/juci-mod-dropbear/tests/test-dropbear.js @@ -1,4 +1,4 @@ -global.JUCI = require("../../../../tests/lib-juci"); +require("../../../../tests/lib-juci"); require("../dropbear"); describe("Dropbear", function(){ diff --git a/luciexpress/htdocs/plugins/wifi/tests/test-wireless.js b/luciexpress/htdocs/plugins/wifi/tests/test-wireless.js index 0d8ed6ace..2cc488a38 100644 --- a/luciexpress/htdocs/plugins/wifi/tests/test-wireless.js +++ b/luciexpress/htdocs/plugins/wifi/tests/test-wireless.js @@ -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(); }); diff --git a/luciexpress/tests/lib-juci.js b/luciexpress/tests/lib-juci.js index d4977bde7..ed1ba898e 100644 --- a/luciexpress/tests/lib-juci.js +++ b/luciexpress/tests/lib-juci.js @@ -59,7 +59,8 @@ function JUCIMock(){ console.log("JUCI.app.controller("+name+")"); _controllers[name] = fn; return self.app; - } + }, + config: function(){} } function LocalStorageMock(){ var _items = {};