assert-diff
Advanced tools
Comparing version 0.0.2 to 0.0.3
var assert = require('assert-plus') | ||
var jdiff = require('json-diff') | ||
var opts = {strict: false} | ||
module.exports = exports = function(options) { | ||
opts = options | ||
return module.exports | ||
} | ||
Object.keys(assert).forEach(function(key) { | ||
@@ -22,4 +28,13 @@ module.exports[key] = function() { | ||
} | ||
if (opts.strict) { | ||
var diff = jdiff.diff(arguments[0], arguments[1]) | ||
if (diff) { | ||
throw new assert.AssertionError({ | ||
message: arguments[2] + '\u001b[m' + '\n' + jdiff.diffString(arguments[0], arguments[1]), | ||
stackStartFunction: assert.AssertionError | ||
}) | ||
} | ||
} | ||
} | ||
exports.deepEqualOrig = assert.deepEqual |
{ | ||
"name": "assert-diff", | ||
"description": "Drop-in replacement for assert to give diff on deepEqual.", | ||
"keywords": ["assert", "diff", "deepEqual", "object", "array"], | ||
"keywords": ["assert", "diff", "deepEqual", "object", "array", "strict"], | ||
"author": "Antti Mattila <pihvi@live.com>", | ||
"repository": "git://github.com/pihvi/assert-diff", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"main": "./lib/assert-diff.js", | ||
@@ -9,0 +9,0 @@ "license": "Apache 2.0", |
@@ -32,1 +32,7 @@ var assert = require('./../lib/assert-diff') | ||
}) | ||
it('strict diff deep equal', function() { | ||
assert.deepEqual({a: 1, b: 2}, {a: true, b: "2"}, "this should not fail") | ||
assert({strict: true}).deepEqual({a: 1}, {a: 1}, "this should not fail") | ||
assert({strict: true}).deepEqual({a: 1, b: 2}, {a: true, b: "2"}, "this should fail") | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14706
76