mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	writing unit test
This commit is contained in:
		| @@ -1423,9 +1423,32 @@ describe('function node', function() { | ||||
|             n1.receive({payload: "foo"}); | ||||
|         }); | ||||
|     }); | ||||
|     it('should timeout if timeout is set', function(done) { | ||||
|         var flow = [{id:"n1",type:"function",wires:[["n2"]],timeout:"10",func:"while(1==1){};\nreturn msg;"}]; | ||||
|         helper.load(functionNode, flow, function() { | ||||
|             var n1 = helper.getNode("n1"); | ||||
|             n1.receive({payload:"foo",topic: "bar"}); | ||||
|             setTimeout(function() { | ||||
|                 try { | ||||
|                     helper.log().called.should.be.true(); | ||||
|                     var logEvents = helper.log().args.filter(function(evt) { | ||||
|                         return evt[0].type == "function"; | ||||
|                     }); | ||||
|                     logEvents.should.have.length(1); | ||||
|                     var msg = logEvents[0][0]; | ||||
|  | ||||
|  | ||||
|  | ||||
|                     msg.should.have.property('level', helper.log().ERROR); | ||||
|                     msg.should.have.property('id', 'n1'); | ||||
|                     msg.should.have.property('type', 'function'); | ||||
|                     should.equal(msg.msg.message, 'Script execution timed out after 10ms'); | ||||
|                     done(); | ||||
|                 } catch(err) { | ||||
|                     done(err); | ||||
|                 } | ||||
|             },50); | ||||
|         }); | ||||
|     }); | ||||
|     | ||||
|     describe("finalize function", function() { | ||||
|  | ||||
|         it('should execute', function(done) { | ||||
| @@ -1717,5 +1740,7 @@ describe('function node', function() { | ||||
|             }); | ||||
|         }); | ||||
|  | ||||
|          | ||||
|  | ||||
|     }); | ||||
| }); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user