mirror of
https://github.com/prymitive/karma
synced 2026-05-05 03:16:51 +00:00
Fix watchdog requires
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
const $ = require("jquery");
|
||||
const moment = require("moment");
|
||||
|
||||
const config = require("./config");
|
||||
const counter = require("./counter");
|
||||
const templates = require("./templates");
|
||||
|
||||
var selectors = {
|
||||
countdown: "#reload-counter"
|
||||
};
|
||||
@@ -14,15 +21,15 @@ function timerTick() {
|
||||
if (lastTs === 0) return;
|
||||
|
||||
// don't raise an error if autorefresh is disabled
|
||||
if (!Config.GetOption("autorefresh").Get()) return;
|
||||
if (!config.getOption("autorefresh").Get()) return;
|
||||
|
||||
var now = moment().utc().unix();
|
||||
if (now - lastTs > maxLag) {
|
||||
$("#errors").html(Templates.Render("fatalError", {
|
||||
$("#errors").html(templates.renderTemplate("fatalError", {
|
||||
lastTs: lastTs,
|
||||
secondsLeft: fatalCountdown
|
||||
})).show();
|
||||
Counter.Unknown();
|
||||
counter.markUnknown();
|
||||
if (!inCountdown) {
|
||||
fatalCountdown = 60;
|
||||
fatalReloadTimer = setTimeout(function() {
|
||||
|
||||
@@ -1,20 +1,27 @@
|
||||
const watchdog = require("./watchdog");
|
||||
const moment = require("moment");
|
||||
|
||||
test("watchdog init()", () => {
|
||||
window.jQuery = require("jquery");
|
||||
const watchdog = require("./watchdog");
|
||||
watchdog.init(1, 1);
|
||||
});
|
||||
|
||||
test("watchdog getLastUpdate() without pong", () => {
|
||||
window.jQuery = require("jquery");
|
||||
const watchdog = require("./watchdog");
|
||||
expect(watchdog.getLastUpdate()).toBe(0);
|
||||
});
|
||||
|
||||
test("watchdog getLastUpdate() with pong", () => {
|
||||
window.jQuery = require("jquery");
|
||||
const watchdog = require("./watchdog");
|
||||
var ts = moment();
|
||||
watchdog.pong(ts);
|
||||
expect(watchdog.getLastUpdate()).toBe(ts.utc().unix());
|
||||
});
|
||||
|
||||
test("watchdog isFatal() should be false by default", () => {
|
||||
window.jQuery = require("jquery");
|
||||
const watchdog = require("./watchdog");
|
||||
expect(watchdog.isFatal()).toBe(false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user