"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Converter_1 = require("../src/Converter");
var assert = require("assert");
var fs = require("fs");
describe("Converter error handling", function () {
    it("should handle quote not closed", function (done) {
        var rs = fs.createReadStream(__dirname + "/data/dataWithUnclosedQuotes");
        var conv = new Converter_1.Converter({});
        conv.on("error", function (err) {
            assert(err.err === "unclosed_quote");
            done();
        });
        rs.pipe(conv);
    });
    it("should handle column number mismatched error", function (done) {
        var rs = fs.createReadStream(__dirname + "/data/dataWithMismatchedColumn");
        var conv = new Converter_1.Converter({
            checkColumn: true
        });
        var tested = false;
        conv.on("error", function (err) {
            if (tested === false) {
                assert(err.err === "column_mismatched");
                tested = true;
                // done();
            }
        });
        conv.on('done', function () {
            assert(tested);
            done();
        });
        rs.pipe(conv);
    });
    it("should treat quote not closed as column_mismatched when alwaysSplitAtEOL is true", function (done) {
        var rs = fs.createReadStream(__dirname + "/data/dataWithUnclosedQuotes");
        var conv = new Converter_1.Converter({
            checkColumn: true,
            alwaysSplitAtEOL: true,
        });
        var tested = false;
        conv.on("error", function (err) {
            if (tested === false) {
                assert(err.err === "column_mismatched");
                tested = true;
            }
        });
        conv.on('done', function () {
            assert(tested);
            done();
        });
        rs.pipe(conv);
    });
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 4740 characters]