mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	add extra test for CSV with odd quotes
This commit is contained in:
		@@ -124,6 +124,24 @@ describe('CSV node', function() {
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        it('should recover from an odd number of quotes in the input', function(done) {
 | 
			
		||||
            var flow = [ { id:"n1", type:"csv", temp:"a,b,c,d,e,f,g", wires:[["n2"]] },
 | 
			
		||||
                    {id:"n2", type:"helper"} ];
 | 
			
		||||
            helper.load(csvNode, flow, function() {
 | 
			
		||||
                var n1 = helper.getNode("n1");
 | 
			
		||||
                var n2 = helper.getNode("n2");
 | 
			
		||||
                n2.on("input", function(msg) {
 | 
			
		||||
                    //console.log(msg);
 | 
			
		||||
                    msg.should.have.property('payload', { a: 1, b: -2, c: '+3', d: 4, e: -5, f: 'ab"cd', g: 'with,a,comma' });
 | 
			
		||||
                    done();
 | 
			
		||||
                });
 | 
			
		||||
                var testString = '"with,a"n,odd",num"ber,of"quotes'+String.fromCharCode(10);
 | 
			
		||||
                n1.emit("input", {payload:testString});
 | 
			
		||||
                testString = '"1","-2","+3","04","-05",ab""cd,"with,a,comma"'+String.fromCharCode(10);
 | 
			
		||||
                n1.emit("input", {payload:testString});
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        it('should be able to use the first line as a template', function(done) {
 | 
			
		||||
            var flow = [ { id:"n1", type:"csv", temp:"a,b,c,d", hdrin:true, wires:[["n2"]] },
 | 
			
		||||
                    {id:"n2", type:"helper"} ];
 | 
			
		||||
@@ -219,7 +237,7 @@ describe('CSV node', function() {
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        it('should convert aan array of arrays back to a multi-line csv', function(done) {
 | 
			
		||||
        it('should convert an array of arrays back to a multi-line csv', function(done) {
 | 
			
		||||
            var flow = [ { id:"n1", type:"csv", temp:"a,b,c,d", wires:[["n2"]] },
 | 
			
		||||
                    {id:"n2", type:"helper"} ];
 | 
			
		||||
            helper.load(csvNode, flow, function() {
 | 
			
		||||
@@ -281,15 +299,15 @@ describe('CSV node', function() {
 | 
			
		||||
        helper.load(csvNode, flow, function() {
 | 
			
		||||
            var n1 = helper.getNode("n1");
 | 
			
		||||
            var n2 = helper.getNode("n2");
 | 
			
		||||
                n2.on("input", function(msg) {
 | 
			
		||||
                    try {
 | 
			
		||||
                        msg.should.have.property('topic', { a: 4, b: 3, c: 2, d: 1 });
 | 
			
		||||
                        msg.should.not.have.property('payload');
 | 
			
		||||
            n2.on("input", function(msg) {
 | 
			
		||||
                try {
 | 
			
		||||
                    msg.should.have.property('topic', { a: 4, b: 3, c: 2, d: 1 });
 | 
			
		||||
                    msg.should.not.have.property('payload');
 | 
			
		||||
 | 
			
		||||
                        done();
 | 
			
		||||
                    }
 | 
			
		||||
                    catch(e) { done(e); }
 | 
			
		||||
                });
 | 
			
		||||
                    done();
 | 
			
		||||
                }
 | 
			
		||||
                catch(e) { done(e); }
 | 
			
		||||
            });
 | 
			
		||||
            var testJson = { d: 1, b: 3, c: 2, a: 4 };
 | 
			
		||||
            n1.emit("input", {topic:testJson});
 | 
			
		||||
        });
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user