1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Update flow state tests to match changes in api

This commit is contained in:
Nick O'Leary 2022-06-29 10:45:06 +01:00
parent f33848e16b
commit 7580f7491a
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -431,7 +431,7 @@ describe("runtime-api/flows", function() {
var startFlows, stopFlows, runtime; var startFlows, stopFlows, runtime;
beforeEach(function() { beforeEach(function() {
let flowsStarted = true; let flowsStarted = true;
let flowsState = "started"; let flowsState = "start";
startFlows = sinon.spy(function(type) { startFlows = sinon.spy(function(type) {
if (type !== "full") { if (type !== "full") {
var err = new Error(); var err = new Error();
@ -442,7 +442,7 @@ describe("runtime-api/flows", function() {
return p; return p;
} }
flowsStarted = true; flowsStarted = true;
flowsState = "started"; flowsState = "start";
return Promise.resolve(); return Promise.resolve();
}); });
stopFlows = sinon.spy(function(type) { stopFlows = sinon.spy(function(type) {
@ -455,7 +455,7 @@ describe("runtime-api/flows", function() {
return p; return p;
} }
flowsStarted = false; flowsStarted = false;
flowsState = "stopped"; flowsState = "stop";
return Promise.resolve(); return Promise.resolve();
}); });
runtime = { runtime = {
@ -473,6 +473,7 @@ describe("runtime-api/flows", function() {
startFlows, startFlows,
stopFlows, stopFlows,
getFlows: function() { return {rev:"currentRev",flows:[]} }, getFlows: function() { return {rev:"currentRev",flows:[]} },
state: function() { return flowsState}
} }
} }
}) })
@ -480,29 +481,25 @@ describe("runtime-api/flows", function() {
it("gets flows run state", async function() { it("gets flows run state", async function() {
flows.init(runtime); flows.init(runtime);
const state = await flows.getState({}) const state = await flows.getState({})
state.should.have.property("started", true) state.should.have.property("state", "start")
state.should.have.property("state", "started")
}); });
it("permits getting flows run state when setting disabled", async function() { it("permits getting flows run state when setting disabled", async function() {
runtime.settings.runtimeState.enabled = false; runtime.settings.runtimeState.enabled = false;
flows.init(runtime); flows.init(runtime);
const state = await flows.getState({}) const state = await flows.getState({})
state.should.have.property("started", true) state.should.have.property("state", "start")
state.should.have.property("state", "started")
}); });
it("start flows", async function() { it("start flows", async function() {
flows.init(runtime); flows.init(runtime);
const state = await flows.setState({requestedState:"start"}) const state = await flows.setState({state:"start"})
state.should.have.property("started", true) state.should.have.property("state", "start")
state.should.have.property("state", "started")
stopFlows.called.should.not.be.true(); stopFlows.called.should.not.be.true();
startFlows.called.should.be.true(); startFlows.called.should.be.true();
}); });
it("stop flows", async function() { it("stop flows", async function() {
flows.init(runtime); flows.init(runtime);
const state = await flows.setState({requestedState:"stop"}) const state = await flows.setState({state:"stop"})
state.should.have.property("started", false) state.should.have.property("state", "stop")
state.should.have.property("state", "stopped")
stopFlows.called.should.be.true(); stopFlows.called.should.be.true();
startFlows.called.should.not.be.true(); startFlows.called.should.not.be.true();
}); });
@ -511,7 +508,7 @@ describe("runtime-api/flows", function() {
runtime.settings.runtimeState.enabled = false; runtime.settings.runtimeState.enabled = false;
flows.init(runtime); flows.init(runtime);
try { try {
await flows.setState({requestedState:"start"}) await flows.setState({state:"start"})
} catch (error) { } catch (error) {
err = error err = error
} }
@ -525,7 +522,7 @@ describe("runtime-api/flows", function() {
runtime.settings.runtimeState.enabled = false; runtime.settings.runtimeState.enabled = false;
flows.init(runtime); flows.init(runtime);
try { try {
await flows.setState({requestedState:"stop"}) await flows.setState({state:"stop"})
} catch (error) { } catch (error) {
err = error err = error
} }
@ -538,7 +535,7 @@ describe("runtime-api/flows", function() {
let err; let err;
flows.init(runtime); flows.init(runtime);
try { try {
await flows.setState({requestedState:"bad-state"}) await flows.setState({state:"bad-state"})
} catch (error) { } catch (error) {
err = error err = error
} }