Merge pull request #4780 from robertjmason/master

Add arrayContaining() definition/test
This commit is contained in:
Masahiro Wakame
2015-07-03 23:12:30 +09:00
2 changed files with 32 additions and 0 deletions
+24
View File
@@ -657,6 +657,30 @@ describe("jasmine.objectContaining", function () {
});
});
describe("jasmine.arrayContaining", function() {
var foo: any;
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;
+8
View File
@@ -47,6 +47,7 @@ declare module jasmine {
function any(aclass: any): Any;
function anything(): Any;
function arrayContaining(sample: any[]): ArrayContaining;
function objectContaining(sample: any): ObjectContaining;
function createSpy(name: string, originalFn?: Function): Spy;
function createSpyObj(baseName: string, methodNames: any[]): any;
@@ -71,6 +72,13 @@ declare module jasmine {
length: number;
[n: number]: T;
}
interface ArrayContaining {
new (sample: any[]): any;
asymmetricMatch(other: any): boolean;
jasmineToString(): string;
}
interface ObjectContaining {
new (sample: any): any;