Browse Source

Add test case for issue #908

pull/909/head
Jérôme Desboeufs 3 years ago
parent
commit
287d26aa8e
No known key found for this signature in database
GPG Key ID: 943299DA725F957A
  1. 27
      tests/node-tests.js

27
tests/node-tests.js

@ -4,6 +4,7 @@ var Papa = require("../papaparse.js");
var fs = require('fs'); var fs = require('fs');
var assert = require('assert'); var assert = require('assert');
var PassThrough = require('stream').PassThrough;
var longSampleRawCsv = fs.readFileSync(__dirname + '/long-sample.csv', 'utf8'); var longSampleRawCsv = fs.readFileSync(__dirname + '/long-sample.csv', 'utf8');
function assertLongSampleParsedCorrectly(parsedCsv) { function assertLongSampleParsedCorrectly(parsedCsv) {
@ -287,4 +288,30 @@ describe('PapaParse', function() {
} }
}); });
}); });
it('should properly parse multi bytes UTF-8 characters splitted in different chunks', function(done) {
var csvFileString = 'first_name,last_name\nFrançois,Mitterrand\n';
var input = new PassThrough();
var parser = Papa.parse(Papa.NODE_STREAM_INPUT, {header: true});
var rows = [];
input.pipe(parser);
parser.on('data', function(row) {
rows.push(row);
});
parser.on('end', function() {
assert.deepEqual(rows, [
{first_name: 'François', last_name: 'Mitterrand'}
]);
done();
});
input.write(Buffer.from(csvFileString).slice(0, 26));
input.write(Buffer.from(csvFileString).slice(26));
input.end();
});
}); });

Loading…
Cancel
Save