Browse Source

Address deepEqual using compare by JSON strings. (#724)

pull/729/head
jseter 5 years ago committed by Sergi Almacellas Abellana
parent
commit
7ad8dda68c
  1. 11
      papaparse.js
  2. 8
      tests/test-cases.js

11
papaparse.js

@ -1364,12 +1364,15 @@ License: MIT
function addError(type, code, msg, row) function addError(type, code, msg, row)
{ {
_results.errors.push({ var error = {
type: type, type: type,
code: code, code: code,
message: msg, message: msg
row: row };
}); if(row !== undefined) {
error.row = row;
}
_results.errors.push(error);
} }
} }

8
tests/test-cases.js

@ -592,7 +592,7 @@ describe('Core Parser Tests', function() {
function generateTest(test) { function generateTest(test) {
(test.disabled ? it.skip : it)(test.description, function() { (test.disabled ? it.skip : it)(test.description, function() {
var actual = new Papa.Parser(test.config).parse(test.input); var actual = new Papa.Parser(test.config).parse(test.input);
assert.deepEqual(JSON.stringify(actual.errors), JSON.stringify(test.expected.errors)); assert.deepEqual(actual.errors, test.expected.errors);
assert.deepEqual(actual.data, test.expected.data); assert.deepEqual(actual.data, test.expected.data);
}); });
} }
@ -1475,7 +1475,7 @@ describe('Parse Tests', function() {
if (test.expected.meta) { if (test.expected.meta) {
assert.deepEqual(actual.meta, test.expected.meta); assert.deepEqual(actual.meta, test.expected.meta);
} }
assert.deepEqual(JSON.stringify(actual.errors), JSON.stringify(test.expected.errors)); assert.deepEqual(actual.errors, test.expected.errors);
assert.deepEqual(actual.data, test.expected.data); assert.deepEqual(actual.data, test.expected.data);
}); });
} }
@ -1556,7 +1556,7 @@ describe('Parse Async Tests', function() {
var config = test.config; var config = test.config;
config.complete = function(actual) { config.complete = function(actual) {
assert.deepEqual(JSON.stringify(actual.errors), JSON.stringify(test.expected.errors)); assert.deepEqual(actual.errors, test.expected.errors);
assert.deepEqual(actual.data, test.expected.data); assert.deepEqual(actual.data, test.expected.data);
done(); done();
}; };
@ -2384,7 +2384,7 @@ describe('Custom Tests', function() {
this.timeout(test.timeout); this.timeout(test.timeout);
} }
test.run(function(actual) { test.run(function(actual) {
assert.deepEqual(JSON.stringify(actual), JSON.stringify(test.expected)); assert.deepEqual(actual, test.expected);
done(); done();
}); });
}); });

Loading…
Cancel
Save