toContain works with array-like objects (Arguments, HTMLCollections, etc)

Fixes #699

Don't rely on Array.prototype.indexOf for testing containment (not in IE8)
This commit is contained in:
Charles Hansen
2014-10-30 11:57:24 -07:00
committed by slackersoft
parent a4d134521a
commit da6813ef0d
3 changed files with 18 additions and 3 deletions

View File

@@ -174,7 +174,7 @@ describe("matchersUtil", function() {
describe("contains", function() {
it("passes when expected is a substring of actual", function() {
expect(j$.matchersUtil.contains("ABC", "B")).toBe(true);
expect(j$.matchersUtil.contains("ABC", "BC")).toBe(true);
});
it("fails when expected is a not substring of actual", function() {
@@ -207,6 +207,15 @@ describe("matchersUtil", function() {
it("fails when actual is null", function() {
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() {