var parseToArray = require('../lib/parseToArray.js');

var noEscape = "127.0.0.1 user-identifier frank 200 2326",
    neResult = ["127.0.0.1", "user-identifier", "frank", "200", "2326"],
    noQuote = "127.0.0.1 user-identifier frank [10/Oct/2000:13:55:36 -0700] 200 2326",
    nqResult = ["127.0.0.1", "user-identifier", "frank", "10/Oct/2000:13:55:36 -0700", "200", "2326"],
    noBracket = "127.0.0.1 user-identifier frank \"GET /apache_pb.gif HTTP/1.0\" 200 2326",
    nbResult = ["127.0.0.1", "user-identifier", "frank", "GET /apache_pb.gif HTTP/1.0", "200", "2326"],
    parseLine = "127.0.0.1 user-identifier frank [10/Oct/2000:13:55:36 -0700] \"GET /apache_pb.gif HTTP/1.0\" 200 2326",
    plResult = ["127.0.0.1", "user-identifier", "frank", "10/Oct/2000:13:55:36 -0700", "GET /apache_pb.gif HTTP/1.0", "200", "2326"];

describe("The array parser", function () {
    var options = {
        escape: [['"', '"'],['[', ']']]
    }, parser;
    beforeEach(function () {
        parser = parseToArray(options);
    });

    it("returns a function", function () {
        expect(typeof parser).toEqual("function");
    });

    it("parses a line with no escape sequences", function () {
        var result = parser(noEscape);
        expect(result).toEqual(neResult);
    });

    it("parses a line with quote escape sequences", function () {
        var result = parser(noBracket);
        expect(result).toEqual(nbResult);
    });

    it("parses a line with bracket escape sequences", function () {
        var result = parser(noQuote);
        expect(result).toEqual(nqResult);
    });

    it("parses a line with bracket escape sequences", function () {
        var result = parser(parseLine);
        expect(result).toEqual(plResult);
    });
});
@@ -822,16 +822,822 @@
 326%22%5D;%0A%0A
+var issueOneRegression = %22123456_123456 my.server.com 123.123.123.123 - - %5B31/Jul/2014:23:00:00 +0000%5D %5C%22GET /?foo=0123456789abcdef01234567&bar=https%253A%252F%252Fgoogle.com&baz=https%253A%252F%252Fapi.reddit.com&bix=https%253A%252F%252Fgithub.com HTTP/1.1%5C%22 200 2341 %5C%22-%5C%22 %5C%22Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36%5C%22 127.0.0.1:8080%22,%0A    issueOneRegressionExpected = %5B%22123456_123456%22, %22my.server.com%22, %22123.123.123.123%22, %22-%22, %22-%22, %2231/Jul/2014:23:00:00 +0000%22, %22GET /?foo=0123456789abcdef01234567&bar=https%253A%252F%252Fgoogle.com&baz=https%253A%252F%252Fapi.reddit.com&bix=https%253A%252F%252Fgithub.com HTTP/1.1%22, %22200%22, %222341%22, %22-%22, %22Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36%22, %22127.0.0.1:8080%22%5D;%0A%0A
 describe
@@ -2551,12 +2551,183 @@
 %0A    %7D);
+%0A%0A    it(%22Does not fail due to issue #1%22, function() %7B%0A        var result = parser(issueOneRegression);%0A        expect(result).toEqual(issueOneRegressionExpected);%0A    %7D);
 %0A%7D);

Add regression test for #1