mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 15:00:26 +00:00
Merge pull request #4780 from robertjmason/master
Add arrayContaining() definition/test
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Vendored
+8
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user