From 9489953a8fa1e24bfc5b39886ac8189a035159fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20L=C3=B8vdal?= Date: Sat, 23 Sep 2023 22:04:48 +0200 Subject: [PATCH] Introduce timeout constant --- test/nodes/core/function/10-function_spec.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/nodes/core/function/10-function_spec.js b/test/nodes/core/function/10-function_spec.js index acb693208..d5d35d77e 100644 --- a/test/nodes/core/function/10-function_spec.js +++ b/test/nodes/core/function/10-function_spec.js @@ -1718,9 +1718,10 @@ describe('function node', function() { describe("init function", function() { it('should delay handling messages until init completes', function(done) { + const timeout_ms = 200; var flow = [{id:"n1",type:"function",wires:[["n2"]],initialize: ` return new Promise((resolve,reject) => { - setTimeout(resolve,200) + setTimeout(resolve, ${timeout_ms}); })`, func:"return msg;" }, @@ -1733,9 +1734,9 @@ describe('function node', function() { msg.delta = Date.now() - msg.payload; receivedMsgs.push(msg) 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) { - 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 { done(); }