Skip to content

Commit

Permalink
Merge pull request #406 from abramsimon/abramsimon/add-test-coverage-…
Browse files Browse the repository at this point in the history
…fromfile-encoding

tests: added data file and test coverage to demonstrate encodings
  • Loading branch information
dogabudak committed Apr 17, 2023
2 parents 1aee76f + 0e12d76 commit 1535bcf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/data/dataWithLatin1Encoding
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Timestamp,Name
1395426422,b�b�
1395426422,Jane
1395426422,Mary
1395426422,Anne
1395426422,Hailey
10 changes: 10 additions & 0 deletions test/testCSVConverter2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ describe("testCSVConverter2", function () {
});
});

it("should parse fromFile with encoding option", function (done) {
var csvFile = __dirname + "/data/dataWithLatin1Encoding";
var conv = new Converter({
});
conv.fromFile(csvFile, { encoding: "latin1" }).then(function (json) {
assert.equal(json[0].Name, 'bébé');
done();
});
});

it("should fromFile should emit error", function (done) {
var csvFile = __dirname + "/data/dataWithUnclosedQuotes";
var conv = new Converter({
Expand Down

0 comments on commit 1535bcf

Please sign in to comment.