Contains is explicitly false if actual is undefined or null

Fix #627
This commit is contained in:
slackersoft
2014-07-18 13:18:22 -07:00
parent 62212bbfa4
commit a1c109ea17
2 changed files with 9 additions and 1 deletions

View File

@@ -199,6 +199,14 @@ describe("matchersUtil", function() {
expect(j$.matchersUtil.contains([1, 2], 2, [customTester])).toBe(true);
});
it("fails when actual is undefined", function() {
expect(j$.matchersUtil.contains(undefined, 'A')).toBe(false);
});
it("fails when actual is null", function() {
expect(j$.matchersUtil.contains(null, 'A')).toBe(false);
});
});
describe("buildMessage", function() {

View File

@@ -19,7 +19,7 @@ getJasmineRequireObj().matchersUtil = function(j$) {
}
return false;
}
return haystack.indexOf(needle) >= 0;
return !!haystack && haystack.indexOf(needle) >= 0;
},
buildFailureMessage: function() {