Skip to content

Commit

Permalink
Merge pull request chaijs#4 from RobertHerhold/master
Browse files Browse the repository at this point in the history
Use Chai to perform diffs
  • Loading branch information
eagleeye authored and koddsson committed Mar 24, 2015
1 parent 968c1eb commit d8bb923
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions lib/chai-subset.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
var CircularJSON = require('circular-json');

module.exports = function(chai) {
chai.Assertion.addChainableMethod('containSubset', function (expected) {
var actual = this.__flags.object;
var msg = "\n" + CircularJSON.stringify(actual, null, "\t") + "\n";
this.assert(
module.exports = function(chai, utils) {
var Assertion = chai.Assertion;
var assertionPrototype = Assertion.prototype;

Assertion.addChainableMethod('containSubset', function (expected) {
var actual = utils.flag(this, 'object');
var showDiff = chai.config.showDiff;

assertionPrototype.assert.call(this,
compare(expected, actual),
'expected' + msg + 'to contain subset \n#{exp}',
'expected' + msg + 'not to contain subset \n#{exp}',
expected
'expected #{act} to contain subset #{exp}',
'expected #{act} to not contain subset #{exp}',
expected,
actual,
showDiff
);
});
};
Expand Down Expand Up @@ -44,4 +50,4 @@ function compare(expected, actual) {
}
return ao === eo;
});
}
}

0 comments on commit d8bb923

Please sign in to comment.