Disable interval handler when running tests

This commit is contained in:
JC Brand 2021-04-23 12:00:29 +02:00
parent ff14a706cf
commit 4b737c1c93

View File

@ -48,15 +48,16 @@ export function onConnected () {
} }
export function onEverySecond () { export function onEverySecond () {
if (!api.connection.connected()) { if (!api.connection.connected() || _converse.isTestEnv()) {
return; return;
} }
if (api.settings.get('ping_interval') > 0) { const ping_interval = api.settings.get('ping_interval');
if (ping_interval > 0) {
const now = new Date(); const now = new Date();
if (!lastStanzaDate) { if (!lastStanzaDate) {
lastStanzaDate = now; lastStanzaDate = now;
} }
if ((now - lastStanzaDate)/1000 > api.settings.get('ping_interval')) { if ((now - lastStanzaDate)/1000 > ping_interval) {
api.ping(); api.ping();
} }
} }