Skip to content

Commit

Permalink
Revert "Fix/newlines in cells (#114)"
Browse files Browse the repository at this point in the history
This reverts commit a8c63f4.

Conflicts:
	test/helpers/load-fixtures.js
	test/index.js
  • Loading branch information
Ilya Radchenko committed Jun 29, 2016
1 parent 27871f4 commit 6fc4213
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 32 deletions.
5 changes: 1 addition & 4 deletions lib/json2csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,7 @@ function createColumnContent(params, str) {
//JSON.stringify('\\') results in a string with two backslash
//characters in it. I.e. '\\\\'.
stringifiedElement = stringifiedElement.replace(/\\\\/g, '\\');

// preserve newlines
stringifiedElement = stringifiedElement.split('\\n').join('\n')


if (params.excelStrings && typeof val === 'string') {
stringifiedElement = '"="' + stringifiedElement + '""';
}
Expand Down
7 changes: 0 additions & 7 deletions test/fixtures/csv/newLineCellContent.csv

This file was deleted.

6 changes: 0 additions & 6 deletions test/fixtures/json/newlines.json

This file was deleted.

1 change: 0 additions & 1 deletion test/helpers/load-fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ var fixtures = [
'fancyfields',
'trailingBackslash',
'excelStrings',
'newLineCellContent',
'overriddenDefaultValue',
'emptyRow',
'emptyRowNotIncluded',
Expand Down
17 changes: 3 additions & 14 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ var jsonNested = require('./fixtures/json/nested');
var jsonDefaultValue = require('./fixtures/json/defaultValue');
var jsonDefaultValueEmpty = require('./fixtures/json/defaultValueEmpty');
var jsonTrailingBackslash = require('./fixtures/json/trailingBackslash');
var jsonNewlines = require('./fixtures/json/newlines');
var jsonOverriddenDefaultValue = require('./fixtures/json/overridenDefaultValue');
var jsonEmptyRow = require('./fixtures/json/emptyRow');
var csvFixtures = {};
Expand Down Expand Up @@ -54,7 +53,7 @@ async.parallel(loadFixtures(csvFixtures), function (err) {
t.end();
});
});


test('should parse json to csv without fields', function (t) {
json2csv({
Expand Down Expand Up @@ -365,7 +364,7 @@ async.parallel(loadFixtures(csvFixtures), function (err) {
t.end();
});
});

test('should escape " when preceeded by \\', function (t){
json2csv({
data: [{field: '\\"'}]
Expand All @@ -375,7 +374,7 @@ async.parallel(loadFixtures(csvFixtures), function (err) {
t.end();
});
});

test('should format strings to force excel to view the values as strings', function (t) {
json2csv({
data: jsonDefault,
Expand All @@ -388,16 +387,6 @@ async.parallel(loadFixtures(csvFixtures), function (err) {
});
});

test('should preserve newlines within cell content', function (t) {
json2csv({
data: jsonNewlines
}, function (error, csv) {
t.error(error);
t.equal(csv, csvFixtures.newLineCellContent);
t.end();
});
});

test('should override defaultValue with field.defaultValue', function (t) {
json2csv({
data: jsonOverriddenDefaultValue,
Expand Down

0 comments on commit 6fc4213

Please sign in to comment.