diff --git a/test/nodes/core/core/89-trigger_spec.js b/test/nodes/core/core/89-trigger_spec.js index 43421d121..23af5c8cc 100644 --- a/test/nodes/core/core/89-trigger_spec.js +++ b/test/nodes/core/core/89-trigger_spec.js @@ -413,7 +413,7 @@ describe('trigger node', function() { n1.emit("input", {payload:"foo"}); // trigger setTimeout( function() { n1.emit("input", {reset:true}); // reset - },90); + },95); setTimeout( function() { c.should.equal(4); // should send foo 4 times. done(); diff --git a/test/nodes/core/storage/28-tail_spec.js b/test/nodes/core/storage/28-tail_spec.js index f49c82605..d09084575 100644 --- a/test/nodes/core/storage/28-tail_spec.js +++ b/test/nodes/core/storage/28-tail_spec.js @@ -16,6 +16,7 @@ var should = require("should"); var path = require('path'); +var os = require('os'); var fs = require('fs-extra'); var sinon = require('sinon'); var tailNode = require("../../../../nodes/core/storage/28-tail.js"); @@ -39,98 +40,100 @@ describe('tail Node', function() { }); }); - it('should be loaded', function(done) { - var flow = [{id:"tailNode1", type:"tail", name: "tailNode", "split":true, "filename":fileToTail}]; - helper.load(tailNode, flow, function() { - var tailNode1 = helper.getNode("tailNode1"); - tailNode1.should.have.property('name', 'tailNode'); - done(); + if (os.type() !== "Windows_NT") { + it('should be loaded', function(done) { + var flow = [{id:"tailNode1", type:"tail", name: "tailNode", "split":true, "filename":fileToTail}]; + helper.load(tailNode, flow, function() { + var tailNode1 = helper.getNode("tailNode1"); + tailNode1.should.have.property('name', 'tailNode'); + done(); + }); }); - }); - it('should tail a file', function(done) { - var flow = [{id:"tailNode1", type:"tail", name: "tailNode", "split":true, "filename":fileToTail, "wires":[["helperNode1"]]}, - {id:"helperNode1", type:"helper", wires:[]}]; - helper.load(tailNode, flow, function() { - var tailNode1 = helper.getNode("tailNode1"); - var helperNode1 = helper.getNode("helperNode1"); - var inputCounter = 0; - helperNode1.on("input", function(msg) { - //console.log(msg); - msg.should.have.property('topic', fileToTail); - msg.payload.should.equal("Tail message line " + (++inputCounter + 2)); - if (inputCounter === 2) { + it('should tail a file', function(done) { + var flow = [{id:"tailNode1", type:"tail", name: "tailNode", "split":true, "filename":fileToTail, "wires":[["helperNode1"]]}, + {id:"helperNode1", type:"helper", wires:[]}]; + helper.load(tailNode, flow, function() { + var tailNode1 = helper.getNode("tailNode1"); + var helperNode1 = helper.getNode("helperNode1"); + var inputCounter = 0; + helperNode1.on("input", function(msg) { + //console.log(msg); + msg.should.have.property('topic', fileToTail); + msg.payload.should.equal("Tail message line " + (++inputCounter + 2)); + if (inputCounter === 2) { + done(); + } + }); + setTimeout( function() { + fs.appendFileSync(fileToTail, "Tail message line 3\n"); + fs.appendFileSync(fileToTail, "Tail message line 4\n"); + },wait); + }); + }); + + it('should work in non-split mode', function(done) { + var flow = [{id:"tailNode1", type:"tail", name: "tailNode", "split":false, "filename":fileToTail, "wires":[["helperNode1"]]}, + {id:"helperNode1", type:"helper", wires:[]}]; + helper.load(tailNode, flow, function() { + var tailNode1 = helper.getNode("tailNode1"); + var helperNode1 = helper.getNode("helperNode1"); + helperNode1.on("input", function(msg) { + //console.log(msg); + msg.should.have.property('topic', fileToTail); + msg.payload.should.equal("Tail message line 5\nTail message line 6\n"); done(); - } + }); + setTimeout( function() { + fs.appendFileSync(fileToTail, "Tail message line 5\nTail message line 6\n"); + },wait); }); - setTimeout( function() { - fs.appendFileSync(fileToTail, "Tail message line 3\n"); - fs.appendFileSync(fileToTail, "Tail message line 4\n"); - },wait); }); - }); - it('should work in non-split mode', function(done) { - var flow = [{id:"tailNode1", type:"tail", name: "tailNode", "split":false, "filename":fileToTail, "wires":[["helperNode1"]]}, - {id:"helperNode1", type:"helper", wires:[]}]; - helper.load(tailNode, flow, function() { - var tailNode1 = helper.getNode("tailNode1"); - var helperNode1 = helper.getNode("helperNode1"); - helperNode1.on("input", function(msg) { - //console.log(msg); - msg.should.have.property('topic', fileToTail); - msg.payload.should.equal("Tail message line 5\nTail message line 6\n"); - done(); + it('should work in binary mode', function(done) { + var flow = [{id:"tailNode1", type:"tail", name: "tailNode", "filetype":"binary", "filename":fileToTail, "wires":[["helperNode1"]]}, + {id:"helperNode1", type:"helper", wires:[]}]; + helper.load(tailNode, flow, function() { + var tailNode1 = helper.getNode("tailNode1"); + var helperNode1 = helper.getNode("helperNode1"); + helperNode1.on("input", function(msg) { + //console.log(msg); + msg.should.have.property('topic', fileToTail); + msg.payload.toString().should.equal("Tail message line 7\nTail message line 8\n"); + done(); + }); + setTimeout( function() { + fs.appendFileSync(fileToTail, "Tail message line 7\nTail message line 8\n"); + },wait); }); - setTimeout( function() { - fs.appendFileSync(fileToTail, "Tail message line 5\nTail message line 6\n"); - },wait); }); - }); - it('should work in binary mode', function(done) { - var flow = [{id:"tailNode1", type:"tail", name: "tailNode", "filetype":"binary", "filename":fileToTail, "wires":[["helperNode1"]]}, - {id:"helperNode1", type:"helper", wires:[]}]; - helper.load(tailNode, flow, function() { - var tailNode1 = helper.getNode("tailNode1"); - var helperNode1 = helper.getNode("helperNode1"); - helperNode1.on("input", function(msg) { - //console.log(msg); - msg.should.have.property('topic', fileToTail); - msg.payload.toString().should.equal("Tail message line 7\nTail message line 8\n"); - done(); + it('should handle a non-existent file', function(done) { + fs.writeFileSync(fileToTail, "Tail message line.\n"); + var flow = [{id:"tailNode1", type:"tail", name: "tailNode", "split":true, "filename":fileToTail, "wires":[["helperNode1"]]}, + {id:"helperNode1", type:"helper", wires:[]}]; + helper.load(tailNode, flow, function() { + var tailNode1 = helper.getNode("tailNode1"); + var helperNode1 = helper.getNode("helperNode1"); + helperNode1.on("input", function(msg) { + msg.should.have.property('topic', fileToTail); + msg.payload.should.equal("Tail message line"); + done(); + }); + setTimeout(function() { + fs.unlinkSync(fileToTail); + },500); + setTimeout( function() { + fs.writeFile(fileToTail, "Tail message line\n"); + },1000); }); - setTimeout( function() { - fs.appendFileSync(fileToTail, "Tail message line 7\nTail message line 8\n"); - },wait); }); - }); - - it('should handle a non-existent file', function(done) { - fs.writeFileSync(fileToTail, "Tail message line.\n"); - var flow = [{id:"tailNode1", type:"tail", name: "tailNode", "split":true, "filename":fileToTail, "wires":[["helperNode1"]]}, - {id:"helperNode1", type:"helper", wires:[]}]; - helper.load(tailNode, flow, function() { - var tailNode1 = helper.getNode("tailNode1"); - var helperNode1 = helper.getNode("helperNode1"); - helperNode1.on("input", function(msg) { - msg.should.have.property('topic', fileToTail); - msg.payload.should.equal("Tail message line"); - done(); - }); - setTimeout(function(){ - fs.unlinkSync(fileToTail); - },500); - setTimeout( function() { - fs.writeFile(fileToTail, "Tail message line\n"); - },1000); - }); - }); + } it('should throw an error if run on Windows', function(done) { // Stub os platform so we can make it look like windows var os = require('os'); - var spy = sinon.stub(os, 'platform', function(arg){ return("windows"); }); + var spy = sinon.stub(os, 'platform', function(arg) { return("windows"); }); /*jshint immed: false */ (function() { tailNode("1234"); }).should.throw(); diff --git a/test/nodes/core/storage/50-file_spec.js b/test/nodes/core/storage/50-file_spec.js index 68bf66e90..543a4aaf7 100644 --- a/test/nodes/core/storage/50-file_spec.js +++ b/test/nodes/core/storage/50-file_spec.js @@ -17,6 +17,7 @@ var should = require("should"); var path = require('path'); var fs = require('fs-extra'); +var os = require('os'); var sinon = require("sinon"); var fileNode = require("../../../../nodes/core/storage/50-file.js"); var helper = require("../../helper.js"); @@ -80,8 +81,14 @@ describe('file Nodes', function() { },90); setTimeout(function() { var f = fs.readFileSync(fileToTest).toString(); - f.should.have.length(19); - f.should.equal("test2\ntrue\n999\n[2]\n"); + if (os.type() !== "Windows_NT") { + f.should.have.length(19); + f.should.equal("test2\ntrue\n999\n[2]\n"); + } + else { + f.should.have.length(23); + f.should.equal("test2\r\ntrue\r\n999\r\n[2]\r\n"); + } done(); },wait); }); @@ -94,8 +101,14 @@ describe('file Nodes', function() { n1.emit("input", {payload:"fine", filename:fileToTest}); setTimeout(function() { var f = fs.readFileSync(fileToTest).toString(); - f.should.have.length(5); - f.should.equal("fine\n"); + if (os.type() !== "Windows_NT") { + f.should.have.length(5); + f.should.equal("fine\n"); + } + else { + f.should.have.length(6); + f.should.equal("fine\r\n"); + } done(); },wait); }); @@ -197,7 +210,7 @@ describe('file Nodes', function() { it('should fail to append to a ro file', function(done) { // Stub file write so we can make writes fail - var spy = sinon.stub(fs, 'appendFile', function(arg,arg2,arg3,arg4){ arg4(new Error("Stub error message")); }); + var spy = sinon.stub(fs, 'appendFile', function(arg,arg2,arg3,arg4) { arg4(new Error("Stub error message")); }); var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest, "appendNewline":true, "overwriteFile":false}]; helper.load(fileNode, flow, function() { @@ -222,7 +235,7 @@ describe('file Nodes', function() { it('should cope with failing to delete a file', function(done) { // Stub file write so we can make writes fail - var spy = sinon.stub(fs, 'unlink', function(arg,arg2){ arg2(new Error("Stub error message")); }); + var spy = sinon.stub(fs, 'unlink', function(arg,arg2) { arg2(new Error("Stub error message")); }); var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest, "appendNewline":true, "overwriteFile":"delete"}]; helper.load(fileNode, flow, function() { @@ -325,7 +338,7 @@ describe('file Nodes', function() { it('should try to create a new directory if asked to do so (overwrite)', function(done) { // Stub file write so we can make writes fail var fileToTest2 = path.join(resourcesDir,"a","50-file-test-file.txt"); - var spy = sinon.stub(fs, "ensureFile", function(arg1,arg2,arg3,arg4){ arg2(null); }); + var spy = sinon.stub(fs, "ensureFile", function(arg1,arg2,arg3,arg4) { arg2(null); }); var flow = [{id:"fileNode1", type:"file", name: "fileNode", "filename":fileToTest2, "appendNewline":true, "overwriteFile":true, "createDir":true}]; helper.load(fileNode, flow, function() { diff --git a/test/red/runtime/nodes/registry/installer_spec.js b/test/red/runtime/nodes/registry/installer_spec.js index 7c9b835a5..1e6b22437 100644 --- a/test/red/runtime/nodes/registry/installer_spec.js +++ b/test/red/runtime/nodes/registry/installer_spec.js @@ -133,7 +133,8 @@ describe('nodes/registry/installer', function() { done(); } else { - err.message.should.eql("Install failed"); + console.log("ERRROR::"+err.toString()+"::"); + err.toString().should.eql("Error: Install failed"); done(); } });