@@ -18,12 +18,14 @@ var should = require("should");
1818var path = require ( 'path' ) ;
1919var fs = require ( 'fs-extra' ) ;
2020var mkdirp = require ( 'mkdirp' ) ;
21+ var sinon = require ( 'sinon' ) ;
2122
2223var tailNode = require ( "../../../../nodes/core/storage/28-tail.js" ) ;
2324var helper = require ( "../../helper.js" ) ;
2425
25- describe ( 'TailNode ' , function ( ) {
26+ describe ( 'tail Node ' , function ( ) {
2627
28+ var wait = 150 ;
2729 var resourcesDir = path . join ( __dirname , ".." , ".." , ".." , "resources" ) ;
2830 var fileToTail = path . join ( resourcesDir , "28-tail-test-file.txt" ) ;
2931
@@ -48,7 +50,7 @@ describe('TailNode', function() {
4850 } ) ;
4951 } ) ;
5052
51- it ( 'tail should tail a file' , function ( done ) {
53+ it ( 'should tail a file' , function ( done ) {
5254 var flow = [ { id :"tailNode1" , type :"tail" , name : "tailNode" , "split" :true , "filename" :fileToTail , "wires" :[ [ "helperNode1" ] ] } ,
5355 { id :"helperNode1" , type :"helper" , wires :[ ] } ] ;
5456 helper . load ( tailNode , flow , function ( ) {
@@ -66,11 +68,11 @@ describe('TailNode', function() {
6668 setTimeout ( function ( ) {
6769 fs . appendFileSync ( fileToTail , "Tail message line 3\n" ) ;
6870 fs . appendFileSync ( fileToTail , "Tail message line 4\n" ) ;
69- } , 100 ) ;
71+ } , wait ) ;
7072 } ) ;
7173 } ) ;
7274
73- it ( 'tail should work in non-split mode' , function ( done ) {
75+ it ( 'should work in non-split mode' , function ( done ) {
7476 var flow = [ { id :"tailNode1" , type :"tail" , name : "tailNode" , "split" :false , "filename" :fileToTail , "wires" :[ [ "helperNode1" ] ] } ,
7577 { id :"helperNode1" , type :"helper" , wires :[ ] } ] ;
7678 helper . load ( tailNode , flow , function ( ) {
@@ -84,11 +86,11 @@ describe('TailNode', function() {
8486 } ) ;
8587 setTimeout ( function ( ) {
8688 fs . appendFileSync ( fileToTail , "Tail message line 5\nTail message line 6\n" ) ;
87- } , 150 ) ;
89+ } , wait ) ;
8890 } ) ;
8991 } ) ;
9092
91- it ( 'tail should handle a non-existent file' , function ( done ) {
93+ it ( 'should handle a non-existent file' , function ( done ) {
9294 fs . unlinkSync ( fileToTail ) ;
9395 var flow = [ { id :"tailNode1" , type :"tail" , name : "tailNode" , "split" :true , "filename" :fileToTail , "wires" :[ [ "helperNode1" ] ] } ,
9496 { id :"helperNode1" , type :"helper" , wires :[ ] } ] ;
@@ -101,10 +103,22 @@ describe('TailNode', function() {
101103 done ( ) ;
102104 } ) ;
103105 setTimeout ( function ( ) {
104- fs . writeFileSync ( fileToTail , "Tail message line\n" ) ;
105- } , 150 ) ;
106+ fs . writeFile ( fileToTail , "Tail message line\n" ) ;
107+ } , wait ) ;
106108 } ) ;
107109 } ) ;
110+
111+ it ( 'should throw an error if run on Windows' , function ( done ) {
112+ // Stub os platform so we can make it look like windows
113+ var os = require ( 'os' ) ;
114+ var spy = sinon . stub ( os , 'platform' , function ( arg ) { return ( "windows" ) ; } ) ;
115+
116+ /*jshint immed: false */
117+ ( function ( ) { tailNode ( "1234" ) ; } ) . should . throw ( ) ;
118+ os . platform . restore ( ) ;
119+ done ( ) ;
120+ } ) ;
121+
108122 /*
109123 it('tail should handle file truncation', function(done) {
110124 var flow = [{id:"tailNode1", type:"tail", name: "tailNode", "split":true, "filename":fileToTail, "wires":[["helperNode1"]]},
@@ -130,7 +144,7 @@ describe('TailNode', function() {
130144 } else {
131145 msg.payload.should.equal("Tail message line append "+inputCounter);
132146 }
133-
147+
134148 if (inputCounter === 5) {
135149 setTimeout(function() {
136150 warned.should.be.true;
@@ -145,7 +159,7 @@ describe('TailNode', function() {
145159 function() { fs.appendFileSync(fileToTail, "Tail message line append 4\n");},
146160 function() { fs.appendFileSync(fileToTail, "Tail message line append 5\n");}
147161 ];
148-
162+
149163 function processAction() {
150164 var action = actions.shift();
151165 action();
@@ -157,7 +171,7 @@ describe('TailNode', function() {
157171 }
158172 setTimeout( function() {
159173 processAction();
160- },150 );
174+ },wait );
161175 });
162176 });
163177 */
0 commit comments