expect(null).toEqual(jasmine.any(Object)) no longer passes

[Finishes #153181443]
Fixes #1255.
This commit is contained in:
Steve Gravrock
2017-11-29 08:10:01 -08:00
parent 9619acf91f
commit a63172f53f
3 changed files with 9 additions and 2 deletions

View File

@@ -1589,7 +1589,7 @@ getJasmineRequireObj().Any = function(j$) {
}
if (this.expectedObject == Object) {
return typeof other == 'object';
return other !== null && typeof other == 'object';
}
if (this.expectedObject == Boolean) {

View File

@@ -68,10 +68,17 @@ describe("Any", function() {
expect(any.asymmetricMatch(new Thing())).toBe(true);
});
it("does not treat null as an Object", function() {
var any = new jasmineUnderTest.Any(Object);
expect(any.asymmetricMatch(null)).toBe(false);
});
it("jasmineToString's itself", function() {
var any = new jasmineUnderTest.Any(Number);
expect(any.jasmineToString()).toEqual('<jasmine.any(Number)>');
expect(any.jasmineToString()).toEqual('<jasmine.any(Number)>');
});
describe("when called without an argument", function() {

View File

@@ -24,7 +24,7 @@ getJasmineRequireObj().Any = function(j$) {
}
if (this.expectedObject == Object) {
return typeof other == 'object';
return other !== null && typeof other == 'object';
}
if (this.expectedObject == Boolean) {