From 7b129ea9d405010b2180b14828c91c6e2dc18bf0 Mon Sep 17 00:00:00 2001 From: robertjmason Date: Tue, 30 Jun 2015 13:09:48 -0700 Subject: [PATCH] Added arrayContaining test --- jasmine/jasmine-tests.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/jasmine/jasmine-tests.ts b/jasmine/jasmine-tests.ts index 1bdf964dd..c4ad63e86 100644 --- a/jasmine/jasmine-tests.ts +++ b/jasmine/jasmine-tests.ts @@ -657,6 +657,30 @@ describe("jasmine.objectContaining", function () { }); }); +describe("jasmine.arrayContaining", function() { + var foo; + + beforeEach(function() { + foo = [1, 2, 3, 4]; + }); + + it("matches arrays with some of the values", function() { + expect(foo).toEqual(jasmine.arrayContaining([3, 1])); + expect(foo).not.toEqual(jasmine.arrayContaining([6])); + }); + + describe("when used with a spy", function() { + it("is useful when comparing arguments", function() { + var callback = jasmine.createSpy('callback'); + + callback([1, 2, 3, 4]); + + expect(callback).toHaveBeenCalledWith(jasmine.arrayContaining([4, 2, 3])); + expect(callback).not.toHaveBeenCalledWith(jasmine.arrayContaining([5, 2])); + }); + }); +}); + describe("Manually ticking the Jasmine Clock", function () { var timerCallback: any;