Fix tests for toEqual diff output in IE

- Merges #1236 from @benchristel
This commit is contained in:
Ben Christel
2016-11-20 12:12:37 -08:00
committed by Gregg Van Hove
parent 54e7a82ef3
commit 41a813521b
4 changed files with 47 additions and 8 deletions

View File

@@ -289,7 +289,22 @@ describe("toEqual", function() {
expect(compareEquals(actual, expected).message).toEqual(message);
});
function constructorIsNotEnumerable() {
// in IE8, the constructor property is not enumerable, even if it is an
// own property of the object.
// Objects that differ only by an own `constructor` property are thus
// considered equal in IE8.
for (var key in {constructor: 1}) {
return false;
}
return true;
}
it("reports mismatches between objects with their own constructor property", function () {
if (constructorIsNotEnumerable()) {
return;
}
function Foo() {}
function Bar() {}
@@ -301,6 +316,10 @@ describe("toEqual", function() {
});
it("reports mismatches between an object with a real constructor and one with its own constructor property", function () {
if (constructorIsNotEnumerable()) {
return;
}
function Foo() {}
function Bar() {}