From 26bf0850d7ba5de2133336ea46508aa73996be2f Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Sun, 19 Jan 2020 01:14:52 +0200 Subject: [PATCH] Stub checkForUpdates in tests --- test/plugins/auth/ldap.js | 7 ++----- test/server.js | 12 ++++++------ test/tests/mergeConfig.js | 6 ++---- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/test/plugins/auth/ldap.js b/test/plugins/auth/ldap.js index 46703de6..d3adfe91 100644 --- a/test/plugins/auth/ldap.js +++ b/test/plugins/auth/ldap.js @@ -129,12 +129,9 @@ describe("LDAP authentication plugin", function() { this.slow(200); let server; - let originalLogInfo; before(function(done) { - originalLogInfo = log.info; - - log.info = () => {}; + stub(log, "info"); server = startLdapServer(done); }); @@ -142,7 +139,7 @@ describe("LDAP authentication plugin", function() { after(function() { server.close(); - log.info = originalLogInfo; + log.info.restore(); }); beforeEach(function() { diff --git a/test/server.js b/test/server.js index cf6ebbe3..c33c9ae2 100644 --- a/test/server.js +++ b/test/server.js @@ -3,28 +3,28 @@ const log = require("../src/log"); const Helper = require("../src/helper"); const expect = require("chai").expect; +const stub = require("sinon").stub; const got = require("got"); const io = require("socket.io-client"); +const changelog = require("../src/plugins/changelog"); describe("Server", function() { // Increase timeout due to unpredictable I/O on CI services this.timeout(process.env.CI ? 25000 : 5000); let server; - let originalLogInfo; before(function() { - originalLogInfo = log.info; - - log.info = () => {}; + stub(log, "info"); + stub(changelog, "checkForUpdates"); server = require("../src/server")(); }); after(function(done) { server.close(done); - - log.info = originalLogInfo; + log.info.restore(); + changelog.checkForUpdates.restore(); }); const webURL = `http://${Helper.config.host}:${Helper.config.port}/`; diff --git a/test/tests/mergeConfig.js b/test/tests/mergeConfig.js index d14b1200..f2ddb449 100644 --- a/test/tests/mergeConfig.js +++ b/test/tests/mergeConfig.js @@ -248,9 +248,7 @@ describe("mergeConfig", function() { }); it("should only merge same type", function() { - const originalLog = log.info; - - log.warn = () => {}; + stub(log, "warn"); expect( mergeConfig( @@ -282,6 +280,6 @@ describe("mergeConfig", function() { shouldBeString: "string", }); - log.warn = originalLog; + log.warn.restore(); }); });