Stub checkForUpdates in tests

This commit is contained in:
Pavel Djundik 2020-01-19 01:14:52 +02:00
parent d5ac13f91c
commit 26bf0850d7
3 changed files with 10 additions and 15 deletions

View File

@ -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() {

View File

@ -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}/`;

View File

@ -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();
});
});