Skip to content

Commit

Permalink
Address deepEqual using compare by JSON strings. (#724)
Browse files Browse the repository at this point in the history
  • Loading branch information
jseter authored and Sergi Almacellas Abellana committed Oct 23, 2019
1 parent e536351 commit 7ad8dda
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
11 changes: 7 additions & 4 deletions papaparse.js
Original file line number Diff line number Diff line change
Expand Up @@ -1364,12 +1364,15 @@ License: MIT

function addError(type, code, msg, row)
{
_results.errors.push({
var error = {
type: type,
code: code,
message: msg,
row: row
});
message: msg
};
if(row !== undefined) {
error.row = row;
}
_results.errors.push(error);
}
}

Expand Down
8 changes: 4 additions & 4 deletions tests/test-cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ describe('Core Parser Tests', function() {
function generateTest(test) {
(test.disabled ? it.skip : it)(test.description, function() {
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);
});
}
Expand Down Expand Up @@ -1475,7 +1475,7 @@ describe('Parse Tests', function() {
if (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);
});
}
Expand Down Expand Up @@ -1556,7 +1556,7 @@ describe('Parse Async Tests', function() {
var config = test.config;

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);
done();
};
Expand Down Expand Up @@ -2384,7 +2384,7 @@ describe('Custom Tests', function() {
this.timeout(test.timeout);
}
test.run(function(actual) {
assert.deepEqual(JSON.stringify(actual), JSON.stringify(test.expected));
assert.deepEqual(actual, test.expected);
done();
});
});
Expand Down

0 comments on commit 7ad8dda

Please sign in to comment.