chore(test/matchers): improve jsonEquals matcher

This commit is contained in:
Nico Rehwaldt 2018-06-27 14:55:20 +02:00 committed by Philipp Fromme
parent 087c9575b5
commit 628e2d1019
1 changed files with 7 additions and 7 deletions

View File

@ -1,16 +1,16 @@
export default function(chai, utils) { export default function(chai, utils) {
utils.addMethod(chai.Assertion.prototype, 'jsonEqual', function(comparison) { utils.addMethod(chai.Assertion.prototype, 'jsonEqual', function(comparison, filter) {
var actual = JSON.stringify(this._obj); var actual = JSON.stringify(this._obj, filter, ' ');
var expected = JSON.stringify(comparison); var expected = JSON.stringify(comparison, filter, ' ');
this.assert( this.assert(
actual == expected, actual == expected,
'expected #{this} to deep equal #{act}', 'expected #{this} to json equal #{exp} but got #{act}',
'expected #{this} not to deep equal #{act}', 'expected #{this} not to json equal #{exp}',
comparison, // expected expected, // expected
this._obj, // actual actual, // actual
true // show diff true // show diff
); );
}); });