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) {
utils.addMethod(chai.Assertion.prototype, 'jsonEqual', function(comparison) {
utils.addMethod(chai.Assertion.prototype, 'jsonEqual', function(comparison, filter) {
var actual = JSON.stringify(this._obj);
var expected = JSON.stringify(comparison);
var actual = JSON.stringify(this._obj, filter, ' ');
var expected = JSON.stringify(comparison, filter, ' ');
this.assert(
actual == expected,
'expected #{this} to deep equal #{act}',
'expected #{this} not to deep equal #{act}',
comparison, // expected
this._obj, // actual
'expected #{this} to json equal #{exp} but got #{act}',
'expected #{this} not to json equal #{exp}',
expected, // expected
actual, // actual
true // show diff
);
});