mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Introduce timeout constant
This commit is contained in:
parent
cef3a01042
commit
9489953a8f
@ -1718,9 +1718,10 @@ describe('function node', function() {
|
|||||||
describe("init function", function() {
|
describe("init function", function() {
|
||||||
|
|
||||||
it('should delay handling messages until init completes', function(done) {
|
it('should delay handling messages until init completes', function(done) {
|
||||||
|
const timeout_ms = 200;
|
||||||
var flow = [{id:"n1",type:"function",wires:[["n2"]],initialize: `
|
var flow = [{id:"n1",type:"function",wires:[["n2"]],initialize: `
|
||||||
return new Promise((resolve,reject) => {
|
return new Promise((resolve,reject) => {
|
||||||
setTimeout(resolve,200)
|
setTimeout(resolve, ${timeout_ms});
|
||||||
})`,
|
})`,
|
||||||
func:"return msg;"
|
func:"return msg;"
|
||||||
},
|
},
|
||||||
@ -1733,9 +1734,9 @@ describe('function node', function() {
|
|||||||
msg.delta = Date.now() - msg.payload;
|
msg.delta = Date.now() - msg.payload;
|
||||||
receivedMsgs.push(msg)
|
receivedMsgs.push(msg)
|
||||||
if (receivedMsgs.length === 5) {
|
if (receivedMsgs.length === 5) {
|
||||||
var errors = receivedMsgs.filter(msg => msg.delta < 200)
|
var errors = receivedMsgs.filter(msg => msg.delta < timeout_ms)
|
||||||
if (errors.length > 0) {
|
if (errors.length > 0) {
|
||||||
done(new Error(`Message received before init completed - was ${msg.delta} expected >300`))
|
done(new Error(`Message received before init completed - was ${msg.delta} expected >${timeout_ms}`))
|
||||||
} else {
|
} else {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user