From fe02eacb45694c0dbe763f8857b148ba90de6a95 Mon Sep 17 00:00:00 2001 From: callemand Date: Mon, 23 Oct 2023 10:26:48 +0200 Subject: [PATCH] Fix test --- server/test/services/mqtt/lib/configureContainer.test.js | 6 +++++- server/test/services/mqtt/lib/connect.test.js | 1 + server/test/services/mqtt/lib/getConfiguration.test.js | 3 +++ server/test/services/mqtt/lib/handleNewMessage.test.js | 1 + server/test/services/mqtt/lib/init.test.js | 3 +++ server/test/services/mqtt/lib/installContainer.test.js | 1 + server/test/services/mqtt/lib/publish.test.js | 1 + server/test/services/mqtt/lib/saveConfiguration.test.js | 3 +++ server/test/services/mqtt/lib/setValue.test.js | 1 + server/test/services/mqtt/lib/unsubscribe.test.js | 1 + server/test/services/mqtt/lib/updateContainer.test.js | 3 +++ 11 files changed, 23 insertions(+), 1 deletion(-) diff --git a/server/test/services/mqtt/lib/configureContainer.test.js b/server/test/services/mqtt/lib/configureContainer.test.js index c808e86bb0..b13c6e9f77 100644 --- a/server/test/services/mqtt/lib/configureContainer.test.js +++ b/server/test/services/mqtt/lib/configureContainer.test.js @@ -5,7 +5,11 @@ const proxiquire = require('proxyquire').noCallThru(); const { assert, fake } = sinon; -const gladys = {}; +const gladys = { + event: { + on: fake.resolves(null), + }, +}; const mqttClient = {}; const serviceId = 'faea9c35-759a-44d5-bcc9-2af1de37b8b4'; diff --git a/server/test/services/mqtt/lib/connect.test.js b/server/test/services/mqtt/lib/connect.test.js index bfd942cdaf..4e0ccfdb1f 100644 --- a/server/test/services/mqtt/lib/connect.test.js +++ b/server/test/services/mqtt/lib/connect.test.js @@ -17,6 +17,7 @@ describe('mqttHandler.connect', () => { const gladys = { event: { emit: fake.returns(null), + on: fake.resolves(null), }, }; const configuration = { diff --git a/server/test/services/mqtt/lib/getConfiguration.test.js b/server/test/services/mqtt/lib/getConfiguration.test.js index b617c66490..ffa76e3a22 100644 --- a/server/test/services/mqtt/lib/getConfiguration.test.js +++ b/server/test/services/mqtt/lib/getConfiguration.test.js @@ -11,6 +11,9 @@ const serviceId = 'faea9c35-759a-44d5-bcc9-2af1de37b8b4'; describe('mqttHandler.getConfiguration', () => { it('should getConfiguration: not Docker', async () => { const gladys = { + event: { + on: fake.resolves(null), + }, variable: { getValue: fake.resolves('value'), }, diff --git a/server/test/services/mqtt/lib/handleNewMessage.test.js b/server/test/services/mqtt/lib/handleNewMessage.test.js index 3365e845ac..d8692caa00 100644 --- a/server/test/services/mqtt/lib/handleNewMessage.test.js +++ b/server/test/services/mqtt/lib/handleNewMessage.test.js @@ -10,6 +10,7 @@ const gladys = { }, event: { emit: fake.returns(null), + on: fake.resolves(null), }, }; diff --git a/server/test/services/mqtt/lib/init.test.js b/server/test/services/mqtt/lib/init.test.js index 4706e6c354..9e9f3b8f0d 100644 --- a/server/test/services/mqtt/lib/init.test.js +++ b/server/test/services/mqtt/lib/init.test.js @@ -10,6 +10,9 @@ const MqttHandler = require('../../../../services/mqtt/lib'); describe('mqttHandler.init', () => { it('should init', async () => { const gladys = { + event: { + on: fake.resolves(null), + }, variable: { getValue: fake.resolves('value'), }, diff --git a/server/test/services/mqtt/lib/installContainer.test.js b/server/test/services/mqtt/lib/installContainer.test.js index 2329c83db0..3745aa031a 100644 --- a/server/test/services/mqtt/lib/installContainer.test.js +++ b/server/test/services/mqtt/lib/installContainer.test.js @@ -36,6 +36,7 @@ describe('mqttHandler.installContainer', () => { const gladys = { event: { emit: fake.resolves(true), + on: fake.resolves(null), }, system: { getNetworkMode: fake.rejects(error), diff --git a/server/test/services/mqtt/lib/publish.test.js b/server/test/services/mqtt/lib/publish.test.js index 7b1cdcacab..4a39b35397 100644 --- a/server/test/services/mqtt/lib/publish.test.js +++ b/server/test/services/mqtt/lib/publish.test.js @@ -9,6 +9,7 @@ const gladys = { }, event: { emit: fake.returns(null), + on: fake.resolves(null), }, }; diff --git a/server/test/services/mqtt/lib/saveConfiguration.test.js b/server/test/services/mqtt/lib/saveConfiguration.test.js index ff3ad0a455..00d945bc55 100644 --- a/server/test/services/mqtt/lib/saveConfiguration.test.js +++ b/server/test/services/mqtt/lib/saveConfiguration.test.js @@ -31,6 +31,9 @@ describe('mqttHandler.saveConfiguration', () => { setValue: fake.resolves('value'), getValue: fake.resolves(true), }, + event: { + on: fake.resolves(null), + }, }; const config = { diff --git a/server/test/services/mqtt/lib/setValue.test.js b/server/test/services/mqtt/lib/setValue.test.js index 2eebbb3979..cbde8a23a0 100644 --- a/server/test/services/mqtt/lib/setValue.test.js +++ b/server/test/services/mqtt/lib/setValue.test.js @@ -10,6 +10,7 @@ const gladys = { }, event: { emit: fake.returns(null), + on: fake.resolves(null), }, }; diff --git a/server/test/services/mqtt/lib/unsubscribe.test.js b/server/test/services/mqtt/lib/unsubscribe.test.js index b37bb0b8aa..dd2f0661bb 100644 --- a/server/test/services/mqtt/lib/unsubscribe.test.js +++ b/server/test/services/mqtt/lib/unsubscribe.test.js @@ -10,6 +10,7 @@ const gladys = { }, event: { emit: fake.returns(null), + on: fake.resolves(null), }, }; diff --git a/server/test/services/mqtt/lib/updateContainer.test.js b/server/test/services/mqtt/lib/updateContainer.test.js index 03e5e23e3b..9f0fcf5ec1 100644 --- a/server/test/services/mqtt/lib/updateContainer.test.js +++ b/server/test/services/mqtt/lib/updateContainer.test.js @@ -20,6 +20,9 @@ const MqttHandler = proxyquire('../../../../services/mqtt/lib', { }); const gladys = { + event: { + on: fake.resolves(null), + }, variable: { setValue: fake.resolves(null), },