Skip to content

Commit 1535bcf

Browse files
authored
Merge pull request #406 from abramsimon/abramsimon/add-test-coverage-fromfile-encoding
tests: added data file and test coverage to demonstrate encodings
2 parents 1aee76f + 0e12d76 commit 1535bcf

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

test/data/dataWithLatin1Encoding

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Timestamp,Name
2+
1395426422,b�b�
3+
1395426422,Jane
4+
1395426422,Mary
5+
1395426422,Anne
6+
1395426422,Hailey

test/testCSVConverter2.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ describe("testCSVConverter2", function () {
7979
});
8080
});
8181

82+
it("should parse fromFile with encoding option", function (done) {
83+
var csvFile = __dirname + "/data/dataWithLatin1Encoding";
84+
var conv = new Converter({
85+
});
86+
conv.fromFile(csvFile, { encoding: "latin1" }).then(function (json) {
87+
assert.equal(json[0].Name, 'bébé');
88+
done();
89+
});
90+
});
91+
8292
it("should fromFile should emit error", function (done) {
8393
var csvFile = __dirname + "/data/dataWithUnclosedQuotes";
8494
var conv = new Converter({

0 commit comments

Comments
 (0)