From 1e3592d884f3d31424e601f55f2ab23f5a7a5a5c Mon Sep 17 00:00:00 2001 From: Ben Hardill Date: Fri, 13 Dec 2024 10:07:16 +0000 Subject: [PATCH] Fix tests --- lib/agent.js | 2 +- test/unit/lib/agent_spec.js | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/agent.js b/lib/agent.js index f423612..94cae7f 100644 --- a/lib/agent.js +++ b/lib/agent.js @@ -261,7 +261,7 @@ class Agent { agentVersion: this.config.version, licensed: this.config.licensed } - if (this.launcher) { + if (this.launcher?.readPackage) { const { modules } = await this.launcher.readPackage() if (module['node-red'] !== 'latest') { state.nodeRedVersion = modules['node-red'] diff --git a/test/unit/lib/agent_spec.js b/test/unit/lib/agent_spec.js index a338b8f..c422dec 100644 --- a/test/unit/lib/agent_spec.js +++ b/test/unit/lib/agent_spec.js @@ -493,7 +493,7 @@ describe('Agent', function () { describe('getState', function () { it('returns partial state', async function () { const agent = createHTTPAgent() - const state = agent.getState() + const state = await agent.getState() state.should.have.property('ownerType', 'none') state.should.have.property('snapshot', null) state.should.have.property('settings', null) @@ -506,7 +506,7 @@ describe('Agent', function () { it('returns partial state with developer mode', async function () { const agent = createHTTPAgent() agent.currentMode = 'developer' - const state = agent.getState() + const state = await agent.getState() state.should.have.property('ownerType', 'none') state.should.have.property('project', null) state.should.have.property('snapshot', null) @@ -525,7 +525,7 @@ describe('Agent', function () { agent.currentSettings = { hash: 'settingsId' } agent.config = { licensed: true } agent.launcher = { state: 'running' } - const state = agent.getState() + const state = await agent.getState() state.should.have.property('ownerType', 'project') state.should.have.property('project', 'projectId') state.should.have.property('snapshot', 'snapshotId') @@ -543,7 +543,7 @@ describe('Agent', function () { agent.currentSettings = { hash: 'settingsId' } agent.config = { licensed: true } agent.launcher = { state: 'running' } - const state = agent.getState() + const state = await agent.getState() state.should.have.property('ownerType', 'application') state.should.have.property('application', 'applicationId') state.should.have.property('snapshot', 'snapshotId') @@ -562,7 +562,7 @@ describe('Agent', function () { agent.currentSettings = { hash: 'settingsId' } agent.currentMode = 'developer' agent.launcher = { state: 'running' } - const state = agent.getState() + const state = await agent.getState() state.should.have.property('project', 'projectId') state.should.have.property('snapshot', 'snapshotId') state.should.have.property('settings', 'settingsId') @@ -581,7 +581,7 @@ describe('Agent', function () { agent.currentSnapshot = { id: 'snapshotId' } agent.currentSettings = { hash: 'settingsId' } agent.currentMode = 'developer' - const state = agent.getState() + const state = await agent.getState() state.should.have.property('project', 'projectId') state.should.have.property('snapshot', 'snapshotId') state.should.have.property('settings', 'settingsId') @@ -598,7 +598,7 @@ describe('Agent', function () { agent.currentSnapshot = { id: 'snapshotId' } agent.currentSettings = { hash: 'settingsId' } agent.launcher = { state: 'running' } - const state = agent.getState() + const state = await agent.getState() ;(state === null).should.be.true() }) }) @@ -1273,7 +1273,7 @@ describe('Agent', function () { const agent2 = createMQTTAgent() // load the project file await agent2.loadProject() - const state = agent2.getState() + const state = await agent2.getState() state.should.have.property('project', null) state.should.have.property('snapshot', null) state.should.have.property('settings', null) @@ -1301,7 +1301,7 @@ describe('Agent', function () { await agent2.start() // fake a check-in what will start the launcher and the attempt to start the tunnel - const state = agent2.getState() + const state = await agent2.getState() await agent2.setState(state) // fail safe this test by checking the launcher was created and start was called @@ -1339,7 +1339,7 @@ describe('Agent', function () { await agent2.start() // fake a check-in what will start the launcher - const state = agent2.getState() + const state = await agent2.getState() await agent2.setState(state) // fail safe this test by checking the launcher was created and start was called