From 4b737c1c934191e9fd656d310d1e1d0b9ba6c5ea Mon Sep 17 00:00:00 2001 From: JC Brand Date: Fri, 23 Apr 2021 12:00:29 +0200 Subject: [PATCH] Disable interval handler when running tests --- src/headless/plugins/ping/utils.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/headless/plugins/ping/utils.js b/src/headless/plugins/ping/utils.js index 50f838c56..d59bc8b18 100644 --- a/src/headless/plugins/ping/utils.js +++ b/src/headless/plugins/ping/utils.js @@ -48,15 +48,16 @@ export function onConnected () { } export function onEverySecond () { - if (!api.connection.connected()) { + if (!api.connection.connected() || _converse.isTestEnv()) { return; } - if (api.settings.get('ping_interval') > 0) { + const ping_interval = api.settings.get('ping_interval'); + if (ping_interval > 0) { const now = new Date(); if (!lastStanzaDate) { lastStanzaDate = now; } - if ((now - lastStanzaDate)/1000 > api.settings.get('ping_interval')) { + if ((now - lastStanzaDate)/1000 > ping_interval) { api.ping(); } }