unexpected
Advanced tools
Comparing version 1.0.11 to 1.0.12
@@ -551,2 +551,6 @@ // Copyright (c) 2013 Sune Simonsen <sune@we-knowhow.dk> | ||
e.actual = this.obj; | ||
// Explicitly tell mocha to stringify and diff arrays and objects, but only when the types are identical and non-primitive: | ||
if (e.actual && e.expected && typeof e.actual === 'object' && typeof e.expected === 'object' && isArray(e.actual) === isArray(e.expected)) { | ||
e.showDiff = true; | ||
} | ||
} | ||
@@ -553,0 +557,0 @@ throw e; |
{ | ||
"name": "unexpected", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"author": "Sune Sloth Simonsen <sune@we-knowhow.dk>", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -316,3 +316,4 @@ # Unexpected | ||
expect([[1], [2]], 'to be an array whose items satisfy', 'to be an array whose items satisfy', 'to be a number'); | ||
expect([[1], [2]], 'to be an array whose items satisfy', | ||
'to be an array whose items satisfy', 'to be a number'); | ||
@@ -319,0 +320,0 @@ expect([[], []], 'to be a non-empty array whose items satisfy', function (item) { |
@@ -188,2 +188,34 @@ /*global describe, it, expect*/ | ||
}); | ||
it("throws an error with showDiff:true when comparing arrays and not negated", function () { | ||
expect(function () { | ||
expect([1], 'to equal', [2]); | ||
}, 'to throw exception', function (e) { | ||
expect(e.showDiff, 'to be ok'); | ||
}); | ||
}); | ||
it("throws an error with showDiff:true when comparing objects and not negated", function () { | ||
expect(function () { | ||
expect({foo: 1}, 'to equal', {foo: 2}); | ||
}, 'to throw exception', function (e) { | ||
expect(e.showDiff, 'to be ok'); | ||
}); | ||
}); | ||
it("throws an error with showDiff:true when comparing an object to an array", function () { | ||
expect(function () { | ||
expect({foo: 1}, 'to equal', []); | ||
}, 'to throw exception', function (e) { | ||
expect(e.showDiff, 'not to be ok'); | ||
}); | ||
}); | ||
it("throws an error without showDiff:true when negated", function () { | ||
expect(function () { | ||
expect({foo: 1}, 'not to equal', {foo: 1}); | ||
}, 'to throw exception', function (e) { | ||
expect(e.showDiff, 'not to be ok'); | ||
}); | ||
}); | ||
}); | ||
@@ -190,0 +222,0 @@ |
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
229378
6774
491