initial commit.

This commit is contained in:
2022-06-06 02:04:50 -04:00
commit 62de970149
1557 changed files with 256441 additions and 0 deletions

57
node_modules/csvtojson/test/testErrorHandle.ts generated vendored Normal file
View File

@@ -0,0 +1,57 @@
import {Converter} from "../src/Converter";
import CSVError from "../src/CSVError";
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({});
conv.on("error", function(err:CSVError) {
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({
checkColumn:true
});
var tested = false;
conv.on("error", function(err:CSVError) {
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({
checkColumn:true,
alwaysSplitAtEOL:true,
});
var tested = false;
conv.on("error", function(err:CSVError) {
if (tested === false) {
assert(err.err === "column_mismatched");
tested = true;
}
});
conv.on('done',function() {
assert(tested);
done();
});
rs.pipe(conv);
});
});