Merge branch 'charleshansen-to_contain_array_like_objects'

This commit is contained in:
slackersoft
2014-10-30 13:08:45 -07:00
3 changed files with 21 additions and 2 deletions
+6 -1
View File
@@ -2195,7 +2195,12 @@ getJasmineRequireObj().matchersUtil = function(j$) {
} }
return false; return false;
} }
return !!haystack && haystack.indexOf(needle) >= 0; if (!haystack) {
return false;
} else {
var indexOf = haystack.indexOf || Array.prototype.indexOf;
return indexOf.call(haystack, needle) >= 0;
}
}, },
buildFailureMessage: function() { buildFailureMessage: function() {
+9
View File
@@ -207,6 +207,15 @@ describe("matchersUtil", function() {
it("fails when actual is null", function() { it("fails when actual is null", function() {
expect(j$.matchersUtil.contains(null, 'A')).toBe(false); expect(j$.matchersUtil.contains(null, 'A')).toBe(false);
}); });
it("passes with array-like objects", function() {
var capturedArgs = null;
function testFunction(){
capturedArgs = arguments;
}
testFunction('foo', 'bar');
expect(j$.matchersUtil.contains(capturedArgs, 'bar')).toBe(true);
});
}); });
describe("buildMessage", function() { describe("buildMessage", function() {
+6 -1
View File
@@ -19,7 +19,12 @@ getJasmineRequireObj().matchersUtil = function(j$) {
} }
return false; return false;
} }
return !!haystack && haystack.indexOf(needle) >= 0; if (!haystack) {
return false;
} else {
var indexOf = haystack.indexOf || Array.prototype.indexOf;
return indexOf.call(haystack, needle) >= 0;
}
}, },
buildFailureMessage: function() { buildFailureMessage: function() {