2018-04-02 19:01:53 +00:00
|
|
|
export default function(chai, utils) {
|
2017-01-19 15:16:56 +00:00
|
|
|
|
2018-06-27 12:55:20 +00:00
|
|
|
utils.addMethod(chai.Assertion.prototype, 'jsonEqual', function(comparison, filter) {
|
2017-01-19 15:16:56 +00:00
|
|
|
|
2018-06-27 12:55:20 +00:00
|
|
|
var actual = JSON.stringify(this._obj, filter, ' ');
|
|
|
|
var expected = JSON.stringify(comparison, filter, ' ');
|
2017-01-19 15:16:56 +00:00
|
|
|
|
|
|
|
this.assert(
|
|
|
|
actual == expected,
|
2018-06-27 12:55:20 +00:00
|
|
|
'expected #{this} to json equal #{exp} but got #{act}',
|
|
|
|
'expected #{this} not to json equal #{exp}',
|
|
|
|
expected, // expected
|
|
|
|
actual, // actual
|
2017-01-19 15:16:56 +00:00
|
|
|
true // show diff
|
|
|
|
);
|
|
|
|
});
|
2018-04-02 19:01:53 +00:00
|
|
|
}
|