mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Pass Date into the Function node sandbox to fix instanceof tests
This commit is contained in:
		| @@ -80,6 +80,7 @@ module.exports = function(RED) { | |||||||
|             console:console, |             console:console, | ||||||
|             util:util, |             util:util, | ||||||
|             Buffer:Buffer, |             Buffer:Buffer, | ||||||
|  |             Date: Date, | ||||||
|             RED: { |             RED: { | ||||||
|                 util: RED.util |                 util: RED.util | ||||||
|             }, |             }, | ||||||
|   | |||||||
| @@ -508,6 +508,22 @@ describe('function node', function() { | |||||||
|         }); |         }); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     it('should use the same Date object from outside the sandbox', function(done) { | ||||||
|  |         var flow = [{id:"n1",type:"function",wires:[["n2"]],func:"msg.payload=global.get('typeTest')(new Date());return msg;"}, | ||||||
|  |                     {id:"n2", type:"helper"}]; | ||||||
|  |         helper.load(functionNode, flow, function() { | ||||||
|  |             var n1 = helper.getNode("n1"); | ||||||
|  |             var n2 = helper.getNode("n2"); | ||||||
|  |             n1.context().global.set("typeTest",function(d) { return d instanceof Date }); | ||||||
|  |             n2.on("input", function(msg) { | ||||||
|  |                 msg.should.have.property('payload', true); | ||||||
|  |                 done(); | ||||||
|  |             }); | ||||||
|  |             n1.receive({payload:"foo",topic: "bar"}); | ||||||
|  |         }); | ||||||
|  |     }); | ||||||
|  |  | ||||||
|     describe('Logger', function () { |     describe('Logger', function () { | ||||||
|         it('should log an Info Message', function (done) { |         it('should log an Info Message', function (done) { | ||||||
|             var flow = [{id: "n1", type: "function", wires: [["n2"]], func: "node.log('test');"}]; |             var flow = [{id: "n1", type: "function", wires: [["n2"]], func: "node.log('test');"}]; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user