chore(test/matchers): improve jsonEquals matcher
This commit is contained in:
parent
087c9575b5
commit
628e2d1019
|
@ -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
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue