diff --git a/types/jasmine/index.d.ts b/types/jasmine/index.d.ts index a87b8b3a86..47a530330b 100644 --- a/types/jasmine/index.d.ts +++ b/types/jasmine/index.d.ts @@ -8,6 +8,7 @@ // Boris Breuer // Chris Yungmann // Giles Roadnight +// Yaroslav Admin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 // For ddescribe / iit use : https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/karma-jasmine/karma-jasmine.d.ts @@ -634,11 +635,8 @@ declare namespace jasmine { interface Spy { (...params: any[]): any; - identity: string; and: SpyAnd; calls: Calls; - mostRecentCall: { args: any[]; }; - argsForCall: any[]; withArgs(...args: any[]): Spy; } @@ -647,6 +645,8 @@ declare namespace jasmine { } interface SpyAnd { + identity: string; + /** By chaining the spy with and.callThrough, the spy will still track all calls to it but in addition it will delegate to the actual implementation. */ callThrough(): Spy; /** By chaining the spy with and.returnValue, all calls to the function will return a specific value. */ diff --git a/types/jasmine/jasmine-tests.ts b/types/jasmine/jasmine-tests.ts index 92f9a21db8..31bdd5f46c 100644 --- a/types/jasmine/jasmine-tests.ts +++ b/types/jasmine/jasmine-tests.ts @@ -335,6 +335,12 @@ describe("A spy", () => { it("stops all execution on a function", () => { expect(bar).toBeNull(); }); + + it("tracks if it was called at all", function () { + foo.setBar(); + + expect(foo.setBar.calls.any()).toEqual(true); + }); }); describe("A spy, when configured to call through", () => { diff --git a/types/jasmine/v2/index.d.ts b/types/jasmine/v2/index.d.ts index 40491f6875..4a15b3d1da 100644 --- a/types/jasmine/v2/index.d.ts +++ b/types/jasmine/v2/index.d.ts @@ -7,6 +7,7 @@ // Lukas Zech // Boris Breuer // Chris Yungmann +// Yaroslav Admin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 // For ddescribe / iit use : https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/karma-jasmine/karma-jasmine.d.ts @@ -623,11 +624,8 @@ declare namespace jasmine { interface Spy { (...params: any[]): any; - identity: string; and: SpyAnd; calls: Calls; - mostRecentCall: { args: any[]; }; - argsForCall: any[]; } type SpyObj = T & { @@ -635,6 +633,8 @@ declare namespace jasmine { } interface SpyAnd { + identity: string; + /** By chaining the spy with and.callThrough, the spy will still track all calls to it but in addition it will delegate to the actual implementation. */ callThrough(): Spy; /** By chaining the spy with and.returnValue, all calls to the function will return a specific value. */ diff --git a/types/jasmine/v2/jasmine-tests.ts b/types/jasmine/v2/jasmine-tests.ts index cef611ee17..fce7c59c9e 100644 --- a/types/jasmine/v2/jasmine-tests.ts +++ b/types/jasmine/v2/jasmine-tests.ts @@ -311,6 +311,12 @@ describe("A spy", () => { it("stops all execution on a function", () => { expect(bar).toBeNull(); }); + + it("tracks if it was called at all", function () { + foo.setBar(); + + expect(foo.setBar.calls.any()).toEqual(true); + }); }); describe("A spy, when configured to call through", () => {